From 6a45b948f64234018cb5b80a5ddc407bc3f88ff1 Mon Sep 17 00:00:00 2001 From: Jover Lee Date: Fri, 8 Mar 2024 11:46:56 -0800 Subject: [PATCH] pathogen-repo-build: always generate AWS Batch Job ID & summary MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- .github/workflows/pathogen-repo-build.yaml | 6 ++++-- .github/workflows/pathogen-repo-build.yaml.in | 6 ++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pathogen-repo-build.yaml b/.github/workflows/pathogen-repo-build.yaml index ce5efe9..226a9f9 100644 --- a/.github/workflows/pathogen-repo-build.yaml +++ b/.github/workflows/pathogen-repo-build.yaml @@ -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 \ diff --git a/.github/workflows/pathogen-repo-build.yaml.in b/.github/workflows/pathogen-repo-build.yaml.in index d647e39..d50a755 100644 --- a/.github/workflows/pathogen-repo-build.yaml.in +++ b/.github/workflows/pathogen-repo-build.yaml.in @@ -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 \