Skip to content

Commit

Permalink
Make nextstrain.org PR from Auspice PR merge ref if available
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
victorlin committed Oct 5, 2022
1 parent 26c678f commit 6e64179
Showing 1 changed file with 23 additions and 16 deletions.
39 changes: 23 additions & 16 deletions .github/workflows/make_prs_for_other_repos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,23 @@ jobs:
env:
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'
Expand All @@ -23,26 +39,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
Expand All @@ -55,9 +59,12 @@ jobs:
committer: 'nextstrain-bot <nextstrain-bot@users.noreply.github.com>'
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

Expand Down

0 comments on commit 6e64179

Please sign in to comment.