From c0b7f61be47acdb9b4f25e2e9c14043078b47298 Mon Sep 17 00:00:00 2001 From: Derek Roberts Date: Thu, 8 Oct 2026 19:23:38 -0700 Subject: [PATCH 1/2] fix(ci): let the ministry list job open its pull request and notify on failure The job pushed to a fixed chore/ministry-name-schema branch, so once that branch existed every later run failed at the push and no pull request was opened. Each run now uses its own branch, skips when a ministry name pull request is already open, commits as github-actions[bot] and assigns DerekRoberts. A notify job opens or updates an issue through workflow-notifier when any scheduled job fails. --- .github/workflows/scheduled.yml | 39 ++++++++++++++++++++++++++------- 1 file changed, 31 insertions(+), 8 deletions(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 4dfdb7a1..6c5c7ed6 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -93,20 +93,26 @@ jobs: id: validate-ministry-list run: node ./index.js - - name: create a branch, commit and push changes + - name: Open a pull request with the new ministry names if: steps.validate-ministry-list.outputs.schemaChanged == 'true' env: GH_TOKEN: ${{ github.token }} - ACTOR: ${{ github.actor }} + TITLE: "fix(schema): update ministry names from gov.bc.ca" run: | set -euo pipefail - git config --local user.name "$ACTOR" - git checkout -b chore/ministry-name-schema + if [ -n "$(gh pr list --state open --search "\"${TITLE}\" in:title" --json number --jq '.[].number')" ]; then + echo "A ministry name pull request is already open" + exit 0 + fi + BRANCH="chore/ministry-names-${GITHUB_RUN_ID}" + git config --local user.name "github-actions[bot]" + git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" + git checkout -b "${BRANCH}" git add ../bcgovpubcode.json - git commit -m "Updating the Schema as changes to ministry names were detected." - git push origin chore/ministry-name-schema - # Create a Pull Request - gh pr create --assignee "mishraomp" --base main --label "chore" --title "Updating the Schema as changes to ministry names were detected." --body "Updating the Schema as changes to ministry names were detected." + git commit -m "${TITLE}" + git push origin "${BRANCH}" + gh pr create --assignee DerekRoberts --base main --head "${BRANCH}" --label chore --title "${TITLE}" \ + --body "The ministry names in the schema no longer match https://www2.gov.bc.ca/gov/content/governments/organizational-structure/ministries-organizations/ministries." soft-delete-removed-pubcodes: name: Soft Delete pubcodes In the Databse which are removed from the repo. @@ -149,3 +155,20 @@ jobs: API_KEY=$(oc get secrets/pubcode --template={{.data.API_KEY}} | base64 -d) API_URL=https://$(oc get ingress/pubcode-api --template='{{(index .spec.rules 0).host}}') API_KEY="${API_KEY}" API_URL="${API_URL}" node index.js + + notify: + name: Notify on failure + needs: [pubcode-crawler, validate-ministry-list, soft-delete-removed-pubcodes] + if: failure() + runs-on: ubuntu-26.04 + permissions: + contents: read + issues: write + pull-requests: read + steps: + - uses: actions/checkout@v7 + - name: Notify on failure + uses: bcgov/actions/workflow-notifier@4026bfd276b8a5839029106099b13edfb594b2c3 # v0.8.0 + with: + title: "fix: failure in ${{ github.workflow }}" + labels: bug From 8660f334d0726eab55b0e1ae5bdff835bb52c647 Mon Sep 17 00:00:00 2001 From: Derek Roberts Date: Thu, 8 Oct 2026 19:29:26 -0700 Subject: [PATCH 2/2] fix(ci): give each ministry list run attempt its own branch A re-run keeps the run id, so a retry after a failed pull request step would hit the same push rejection. --- .github/workflows/scheduled.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/scheduled.yml b/.github/workflows/scheduled.yml index 6c5c7ed6..fa02a85f 100644 --- a/.github/workflows/scheduled.yml +++ b/.github/workflows/scheduled.yml @@ -104,7 +104,7 @@ jobs: echo "A ministry name pull request is already open" exit 0 fi - BRANCH="chore/ministry-names-${GITHUB_RUN_ID}" + BRANCH="chore/ministry-names-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}" git config --local user.name "github-actions[bot]" git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" git checkout -b "${BRANCH}"