From 18199bca9383919b109d787f5431daf81477fe88 Mon Sep 17 00:00:00 2001 From: Victor Lin <13424970+victorlin@users.noreply.github.com> Date: Wed, 5 Oct 2022 15:22:54 -0700 Subject: [PATCH] Make nextstrain.org PR from Auspice PR merge ref if available Previously, Auspice was installed from the source branch HEAD directly. This can fail to catch issues if there are notable changes in the PR target branch unincorporated in the source branch. Creating the nextstrain.org PR from the auto-merged ref should surface any merge-related issues sooner than later. --- .../workflows/make_prs_for_other_repos.yaml | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/.github/workflows/make_prs_for_other_repos.yaml b/.github/workflows/make_prs_for_other_repos.yaml index 3c6c3c996..e6aab650f 100644 --- a/.github/workflows/make_prs_for_other_repos.yaml +++ b/.github/workflows/make_prs_for_other_repos.yaml @@ -13,6 +13,23 @@ jobs: DESTINATION_REPO_DIR: nextstrain.org steps: + # If a PR exists for this branch, also update the local copy of Auspice + # to the GitHub-managed merge ref. + - name: Detect PR from branch + id: detect-pr + run: | + PR_NUMBER=$(gh pr view $GITHUB_REF_NAME --repo nextstrain/auspice --json 'number' --jq '.number') || true + if [[ -n $PR_NUMBER ]]; then + echo "::set-output name=markdown-text::[PR $PR_NUMBER](https://github.com/nextstrain/auspice/pull/$PR_NUMBER)" + $MERGE_SHA=$(gh pr view $GITHUB_REF_NAME --repo nextstrain/auspice --json 'potentialMergeCommit' --jq '.potentialMergeCommit.oid') + echo "::set-output name=auspice-sha::$MERGE_SHA" + else + echo "::set-output name=markdown-text::[branch $GITHUB_REF_NAME](https://github.com/nextstrain/auspice/tree/$GITHUB_REF_NAME)" + echo "::set-output name=auspice-sha::$GITHUB_SHA" + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + - uses: actions/setup-node@v2 with: node-version: '14' @@ -23,26 +40,14 @@ jobs: repository: nextstrain/nextstrain.org path: ${{ env.DESTINATION_REPO_DIR }} - - name: Install Auspice from source branch HEAD commit + - name: Install Auspice shell: bash working-directory: ${{ env.DESTINATION_REPO_DIR }} run: | npm ci - npm install nextstrain/auspice#${GITHUB_SHA} + npm install nextstrain/auspice#${{ steps.detect-pr.outputs.auspice-sha }} git add package.json package-lock.json - - name: Generate Markdown link - id: generate-markdown-link - run: | - PR_NUMBER=$(gh pr view $GITHUB_REF_NAME --repo nextstrain/auspice --json 'number' --jq '.number') || true - if [[ -n $PR_NUMBER ]]; then - echo "::set-output name=text::[PR $PR_NUMBER](https://github.com/nextstrain/auspice/pull/$PR_NUMBER)" - else - echo "::set-output name=text::[branch $GITHUB_REF_NAME](https://github.com/nextstrain/auspice/tree/$GITHUB_REF_NAME)" - fi - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Create Pull Request for testing on nextstrain.org repo id: cpr uses: peter-evans/create-pull-request@v3 @@ -55,9 +60,12 @@ jobs: committer: 'nextstrain-bot ' title: '[bot] [DO NOT MERGE] Test Auspice branch ${{ github.ref_name }}' body: | - This PR has been created to test Auspice from ${{ steps.generate-markdown-link.outputs.text }}. + This PR has been created to test Auspice from ${{ steps.detect-pr.outputs.markdown-text }}. This message and corresponding commits were automatically created by a GitHub Action from [nextstrain/auspice](https://github.com/nextstrain/auspice). + + If there is an open PR for the branch, then Auspice has been installed from the result of the branch merged with the PR's target branch. + This will surface any issues that can arise from merging the PR in Auspice. To address these issues locally, update the source branch (e.g. with a git rebase). draft: true delete-branch: true