From 39228dd1df592dc92d6a758342ab3b3f10adcc8c Mon Sep 17 00:00:00 2001 From: Graeme Porteous Date: Thu, 26 Oct 2023 09:49:50 +0100 Subject: [PATCH] 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