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