Skip to content

Commit

Permalink
ci: fix notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
auricom committed Dec 4, 2024
1 parent 490625c commit 6af3220
Showing 1 changed file with 50 additions and 23 deletions.
73 changes: 50 additions & 23 deletions .github/workflows/build-applications.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -436,36 +436,63 @@ jobs:
with:
script: |
const branch = context.ref.replace('refs/heads/', '');
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'nightlies-scheduled.yaml',
branch: branch,
status: 'completed',
per_page: 1
});
return runs.data.workflow_runs[0].id;
try {
const runs = await github.rest.actions.listWorkflowRuns({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'nightlies-scheduled.yaml',
branch: branch,
status: 'completed',
per_page: 1
});
if (!runs.data.workflow_runs.length) {
console.log('No previous workflow runs found');
return '';
}
return runs.data.workflow_runs[0].id;
} catch (error) {
console.error('Error fetching workflow runs:', error);
return '';
}
- name: Check specific matrix job
id: check-matrix
if: steps.get-previous-run.outputs.result
if: steps.get-previous-run.outputs.result != ''
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7
with:
script: |
const run_id = ${{ steps.get-previous-run.outputs.result }};
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run_id
});
const specificJob = jobs.data.jobs.find(job =>
job.name === 'Build Images / Merge ${{ matrix.app.name }} ${{ matrix.app.channel }}'
);
const wasSuccessful = specificJob && specificJob.conclusion === 'success';
console.log(`The specific matrix job was ${wasSuccessful ? 'successful' : 'not successful'}`);
core.setOutput('was-successful', wasSuccessful);
try {
const jobs = await github.rest.actions.listJobsForWorkflowRun({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: run_id
});
const expectedJobName = `Build Images / Merge ${context.payload.inputs.app_name} ${context.payload.inputs.channel}`;
console.log('Looking for job with name:', expectedJobName);
console.log('Available jobs:');
jobs.data.jobs.forEach(job => {
console.log(`- ${job.name} (${job.conclusion})`);
});
const specificJob = jobs.data.jobs.find(job => job.name === expectedJobName);
if (!specificJob) {
console.log('Job not found!');
core.setOutput('was-successful', false);
return;
}
const wasSuccessful = specificJob.conclusion === 'success';
console.log(`Found job. Conclusion: ${specificJob.conclusion}`);
core.setOutput('was-successful', wasSuccessful);
} catch (error) {
console.error('Error checking job status:', error);
core.setOutput('was-successful', false);
}
# - name: Notify Slack
# if: inputs.sendNotifications == 'true' && ((steps.check-matrix.outputs.was-successful && env.app_status != 'true') || (!steps.check-matrix.outputs.was-successful && env.app_status == 'true'))
Expand Down

0 comments on commit 6af3220

Please sign in to comment.