Skip to content

Commit

Permalink
pathogen-repo-build: always generate AWS Batch Job ID & summary
Browse files Browse the repository at this point in the history
Ran into a workflow run where the `run-build` step failed and the job
exited without generating the AWS Batch Job ID or summary.¹

This commit updates the condition to always try to generate the AWS
Batch ID as long as the runtime is `aws-batch` and the `build.log` file
exists. This then allows the workflow to always generate the AWS Batch
Job summary even if the build failed.

¹ https://github.com/nextstrain/forecasts-ncov/actions/runs/8203385071
  • Loading branch information
joverlee521 committed Mar 8, 2024
1 parent 3bcc299 commit 6a45b94
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions .github/workflows/pathogen-repo-build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -275,12 +275,14 @@ jobs:
set -x
eval "$NEXTSTRAIN_BUILD_COMMAND" |& tee build.log
- if: ${{ inputs.runtime == 'aws-batch' }}
# Attempt to get the AWS Batch ID even if the run build command failed
# as long as the runtime is `aws-batch` and the `build.log` file exists
- if: ${{ always() && inputs.runtime == 'aws-batch' && hashFiles('build.log') != '' }}
name: Get AWS Batch job id
id: aws-batch
run: |
echo "AWS_BATCH_JOB_ID=$(sed -nE 's/.+AWS Batch Job ID\:.+ ([-a-f0-9]+)$/\1/p' < build.log)" >> "$GITHUB_ENV"
- if: env.AWS_BATCH_JOB_ID
- if: ${{ always() && env.AWS_BATCH_JOB_ID }}
name: Generate AWS Batch summary
run: |
"$NEXTSTRAIN_GITHUB_DIR"/bin/interpolate-env < "$NEXTSTRAIN_GITHUB_DIR"/text-templates/attach-aws-batch.md \
Expand Down
6 changes: 4 additions & 2 deletions .github/workflows/pathogen-repo-build.yaml.in
Original file line number Diff line number Diff line change
Expand Up @@ -242,13 +242,15 @@ jobs:

eval "$NEXTSTRAIN_BUILD_COMMAND" |& tee build.log

- if: ${{ inputs.runtime == 'aws-batch' }}
# Attempt to get the AWS Batch ID even if the run build command failed
# as long as the runtime is `aws-batch` and the `build.log` file exists
- if: ${{ always() && inputs.runtime == 'aws-batch' && hashFiles('build.log') != '' }}
name: Get AWS Batch job id
id: aws-batch
run: |
echo "AWS_BATCH_JOB_ID=$(sed -nE 's/.+AWS Batch Job ID\:.+ ([-a-f0-9]+)$/\1/p' < build.log)" >> "$GITHUB_ENV"

- if: env.AWS_BATCH_JOB_ID
- if: ${{ always() && env.AWS_BATCH_JOB_ID }}
name: Generate AWS Batch summary
run: |
"$NEXTSTRAIN_GITHUB_DIR"/bin/interpolate-env < "$NEXTSTRAIN_GITHUB_DIR"/text-templates/attach-aws-batch.md \
Expand Down

0 comments on commit 6a45b94

Please sign in to comment.