From f27a27fb7d11755ecb6ebc0b65f20e8ddcbf0321 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 | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e8a2d99d..d05dfd58 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -40,13 +40,35 @@ jobs: env: DATABASE_URL: postgres://postgres:postgres@localhost:5432/alaveteli_test RAILS_ENV: test + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} steps: + - name: Get theme PR description + id: pr_theme_description + run: | + PR_DESCRIPTION=$(gh pr view https://github.com/mysociety/whatdotheyknow-theme/pull/${{ github.event.pull_request.number }} --json body -q '.body') + echo $PR_DESCRIPTION + echo "PR_DESCRIPTION=$PR_DESCRIPTION" >> $GITHUB_ENV + + - name: Extract associated required core PR number + id: pr_core_number + run: | + echo "PR_CORE_NUMBER=$(echo $PR_DESCRIPTION | grep -o 'https://github.com/mysociety/alaveteli/pull/[0-9]*' | grep -o '[0-9]*$')" >> $GITHUB_ENV + + - name: Get core branch name + id: pr_core_branch + run: | + if [[ ! -z "$PR_CORE_NUMBER" ]]; then + echo "PR_CORE_BRANCH=$(gh pr view https://github.com/mysociety/alaveteli/pull/$PR_CORE_NUMBER --json headRefName -q '.headRefName')" >> $GITHUB_ENV + else + echo "PR_CORE_BRANCH=develop" >> $GITHUB_ENV + fi + - name: Checkout Alaveteli uses: actions/checkout@v2 with: repository: mysociety/alaveteli - ref: develop + ref: $PR_CORE_BRANCH path: core submodules: true fetch-depth: 0