From eb00147fdec843da39c7e6970af3c4e775dc44eb Mon Sep 17 00:00:00 2001 From: Graeme Porteous Date: Fri, 14 Jul 2023 10:08:26 +0100 Subject: [PATCH 1/2] Update mirroring workflow Prevent CI and RuboCop from being run twice. --- .github/workflows/ci.yml | 1 - .github/workflows/mirror.yml | 13 ++++--------- .github/workflows/rubocop.yml | 3 ++- 3 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8a2d99d..a203bee9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -4,7 +4,6 @@ on: push: branches: [master, develop] pull_request: - workflow_call: concurrency: group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} diff --git a/.github/workflows/mirror.yml b/.github/workflows/mirror.yml index cdf32758..437db1be 100644 --- a/.github/workflows/mirror.yml +++ b/.github/workflows/mirror.yml @@ -5,18 +5,13 @@ name: Mirror to git.mysociety.org on: - push: + workflow_run: + workflows: [CI] + types: + - completed jobs: - - ci: - uses: ./.github/workflows/ci.yml - - rubocop: - uses: ./.github/workflows/rubocop.yml - mirror: - needs: [ci, rubocop] runs-on: ubuntu-latest steps: diff --git a/.github/workflows/rubocop.yml b/.github/workflows/rubocop.yml index 6c1ca8ce..2bf6ad15 100644 --- a/.github/workflows/rubocop.yml +++ b/.github/workflows/rubocop.yml @@ -1,6 +1,7 @@ name: RuboCop -on: [pull_request, workflow_call] +on: + pull_request: permissions: contents: read From 39228dd1df592dc92d6a758342ab3b3f10adcc8c Mon Sep 17 00:00:00 2001 From: Graeme Porteous Date: Thu, 26 Oct 2023 09:49:50 +0100 Subject: [PATCH 2/2] Update CI GitHub workflow Allow PRs to checkout non develop branch from core Alaveteli. This is useful for PRs which depend on core changes in order to work. --- .github/workflows/ci.yml | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a203bee9..71056685 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -39,13 +39,29 @@ jobs: env: DATABASE_URL: postgres://postgres:postgres@localhost:5432/alaveteli_test RAILS_ENV: test + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: + - name: Extract associated required Alaveteli PR number + id: pr_alaveteli_number + run: | + PR_DESCRIPTION=$(gh pr view https://github.com/mysociety/whatdotheyknow-theme/pull/${{ github.event.pull_request.number }} --json body -q '.body') + echo "PR_ALAVETELI_NUMBER=$(echo $PR_DESCRIPTION | grep -o 'https://github.com/mysociety/alaveteli/pull/[0-9]*' | grep -o '[0-9]*$')" >> $GITHUB_ENV + + - name: Get Alaveteli branch name + id: pr_alaveteli_branch + run: | + if [[ ! -z "$PR_ALAVETELI_NUMBER" ]]; then + echo "PR_ALAVETELI_BRANCH=$(gh pr view https://github.com/mysociety/alaveteli/pull/$PR_ALAVETELI_NUMBER --json headRefName -q '.headRefName')" >> $GITHUB_ENV + else + echo "PR_ALAVETELI_BRANCH=develop" >> $GITHUB_ENV + fi + - name: Checkout Alaveteli uses: actions/checkout@v2 with: repository: mysociety/alaveteli - ref: develop + ref: ${{ env.PR_ALAVETELI_BRANCH }} path: core submodules: true fetch-depth: 0