Skip to content

Commit

Permalink
notify-on-job-start/fail: replace repo_name with github_repo
Browse files Browse the repository at this point in the history
Using GitHub repos by org/name pair to make scripts more generalizable.
This will also work really well with the `GITHUB_REPOSITORY` variable
available for GitHub Action workflows.

Co-authored-by: Victor Lin <13424970+victorlin@users.noreply.github.com>
  • Loading branch information
joverlee521 and victorlin committed Jul 26, 2023
1 parent b663e17 commit b2a0de7
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions notify-on-job-fail
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ set -euo pipefail

bin="$(dirname "$0")"
job_name="${1:?A job name is required as the first argument}"
repo_name="${2:?A repository name is required as the second argument}"
github_repo="${2:?A GitHub repository with owner and repository name is required as the second argument}"

echo "Notifying Slack about failed ${job_name} job."
message="${job_name} job has FAILED 😞 "

if [[ -n "${AWS_BATCH_JOB_ID}" ]]; then
message+="See AWS Batch job \`${AWS_BATCH_JOB_ID}\` (<https://console.aws.amazon.com/batch/v2/home?region=us-east-1#jobs/detail/${AWS_BATCH_JOB_ID}|link>) for error details. "
elif [[ -n "${GITHUB_RUN_ID}" ]]; then
message+="See GitHub Action <https://github.com/nextstrain/${repo_name}/actions/runs/${GITHUB_RUN_ID}?check_suite_focus=true|${GITHUB_RUN_ID}> for error details. "
message+="See GitHub Action <https://github.com/${github_repo}/actions/runs/${GITHUB_RUN_ID}?check_suite_focus=true|${GITHUB_RUN_ID}> for error details. "
fi

"$bin"/notify-slack "$message"
6 changes: 3 additions & 3 deletions notify-on-job-start
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ set -euo pipefail

bin="$(dirname "$0")"
job_name="${1:?A job name is required as the first argument}"
repo_name="${2:?A repository name is required as the second argument}"
github_repo="${2:?A GitHub repository with owner and repository name is required as the second argument}"
build_dir="${3:-ingest}"

echo "Notifying Slack about started ${job_name} job."
message="${job_name} job has started."

if [[ -n "${GITHUB_RUN_ID}" ]]; then
message+=" The job was submitted by GitHub Action <https://github.com/nextstrain/${repo_name}/actions/runs/${GITHUB_RUN_ID}?check_suite_focus=true|${GITHUB_RUN_ID}>."
message+=" The job was submitted by GitHub Action <https://github.com/${github_repo}/actions/runs/${GITHUB_RUN_ID}?check_suite_focus=true|${GITHUB_RUN_ID}>."
fi

if [[ -n "${AWS_BATCH_JOB_ID}" ]]; then
message+=" The job was launched as AWS Batch job \`${AWS_BATCH_JOB_ID}\` (<https://console.aws.amazon.com/batch/v2/home?region=us-east-1#jobs/detail/${AWS_BATCH_JOB_ID}|link>)."
message+=" Follow along in your local \`${repo_name}\` repo with: "'```'"nextstrain build --aws-batch --no-download --attach ${AWS_BATCH_JOB_ID} ${build_dir}"'```'
message+=" Follow along in your local clone of ${github_repo} with: "'```'"nextstrain build --aws-batch --no-download --attach ${AWS_BATCH_JOB_ID} ${build_dir}"'```'
fi

"$bin"/notify-slack "$message"

0 comments on commit b2a0de7

Please sign in to comment.