-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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.
- Loading branch information
Showing
1 changed file
with
23 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 <[email protected]>' | ||
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 | ||
|
||
|