From 27b49a70ba618f89ce9db7b2358416c86c85e6d6 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 | 23 +++++++++++++------ 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/make_prs_for_other_repos.yaml b/.github/workflows/make_prs_for_other_repos.yaml index d44aa00e8..c8fc863d4 100644 --- a/.github/workflows/make_prs_for_other_repos.yaml +++ b/.github/workflows/make_prs_for_other_repos.yaml @@ -13,14 +13,20 @@ jobs: DESTINATION_REPO_DIR: nextstrain.org steps: - - name: Generate Markdown link - id: generate-markdown-link + # If a PR exists for this branch, set the Auspice SHA for npm install to + # the GitHub-managed merge ref. Otherwise, just use the GITHUB_SHA from + # workflow_dispatch which represents the branch HEAD. + - 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=text::[PR $PR_NUMBER](https://github.com/nextstrain/auspice/pull/$PR_NUMBER)" + 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=text::[branch $GITHUB_REF_NAME](https://github.com/nextstrain/auspice/tree/$GITHUB_REF_NAME)" + 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 }} @@ -35,12 +41,12 @@ 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: Create Pull Request for testing on nextstrain.org repo @@ -55,9 +61,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