From f27330742825110029b00d75e73ad673c0c7de98 Mon Sep 17 00:00:00 2001
From: Victor Lin <13424970+victorlin@users.noreply.github.com>
Date: Wed, 10 Apr 2024 12:15:46 -0700
Subject: [PATCH 1/3] Move away from deprecated set-output
Removes the warnings from the workflow summary page.
---
.github/workflows/make_pr_for_downstream_repo.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/make_pr_for_downstream_repo.yaml b/.github/workflows/make_pr_for_downstream_repo.yaml
index fcf9871de..562a0c1e7 100644
--- a/.github/workflows/make_pr_for_downstream_repo.yaml
+++ b/.github/workflows/make_pr_for_downstream_repo.yaml
@@ -40,8 +40,8 @@ jobs:
exit 1
fi
MERGE_SHA=$(gh pr view $GITHUB_REF_NAME --repo nextstrain/auspice --json 'potentialMergeCommit' --jq '.potentialMergeCommit.oid')
- echo "::set-output name=pr-number::$PR_NUMBER"
- echo "::set-output name=auspice-sha::$MERGE_SHA"
+ echo "pr-number=$PR_NUMBER" >> $GITHUB_OUTPUT
+ echo "auspice-sha=$MERGE_SHA" >> $GITHUB_OUTPUT
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
From e871ecb323145b72253d8ea722c09aaf4aab142f Mon Sep 17 00:00:00 2001
From: Victor Lin <13424970+victorlin@users.noreply.github.com>
Date: Wed, 10 Apr 2024 11:22:39 -0700
Subject: [PATCH 2/3] Show PR info in job summary
Job summaries are more visible than log messages from a step.
---
.github/workflows/make_pr_for_downstream_repo.yaml | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/.github/workflows/make_pr_for_downstream_repo.yaml b/.github/workflows/make_pr_for_downstream_repo.yaml
index 562a0c1e7..153130861 100644
--- a/.github/workflows/make_pr_for_downstream_repo.yaml
+++ b/.github/workflows/make_pr_for_downstream_repo.yaml
@@ -86,5 +86,5 @@ jobs:
- name: Check outputs
run: |
- echo "PR number: ${{ steps.cpr.outputs.pull-request-number }}"
- echo "PR URL: ${{ steps.cpr.outputs.pull-request-url }}"
+ echo "PR number: ${{ steps.cpr.outputs.pull-request-number }}" >> "$GITHUB_STEP_SUMMARY"
+ echo "PR URL: ${{ steps.cpr.outputs.pull-request-url }}" >> "$GITHUB_STEP_SUMMARY"
From c4483021cf13d663198f9ff700231ffe8aecb061 Mon Sep 17 00:00:00 2001
From: Victor Lin <13424970+victorlin@users.noreply.github.com>
Date: Wed, 10 Apr 2024 11:10:33 -0700
Subject: [PATCH 3/3] Create PRs on other repos with GitHub CLI
No functional change here except removal of the PR number from the job
summary (URL is more directly available and useful).
---
.../make_pr_for_downstream_repo.yaml | 35 +++++++++++--------
1 file changed, 21 insertions(+), 14 deletions(-)
diff --git a/.github/workflows/make_pr_for_downstream_repo.yaml b/.github/workflows/make_pr_for_downstream_repo.yaml
index 153130861..77b851395 100644
--- a/.github/workflows/make_pr_for_downstream_repo.yaml
+++ b/.github/workflows/make_pr_for_downstream_repo.yaml
@@ -54,6 +54,7 @@ jobs:
with:
repository: ${{ inputs.repository }}
path: ${{ env.DESTINATION_REPO_DIR }}
+ token: ${{ secrets.GH_TOKEN_NEXTSTRAIN_BOT_REPO }}
- name: Install Auspice from PRs HEAD commit
shell: bash
@@ -63,16 +64,15 @@ jobs:
npm install nextstrain/auspice#${{ steps.detect-pr.outputs.auspice-sha }}
git add package.json package-lock.json
+ git config user.name "nextstrain-bot"
+ git config user.email "nextstrain-bot@users.noreply.github.com"
+ git commit --message="[testing only] Upgrade Auspice to ${{ github.sha }}"
+
- name: Create Pull Request
id: cpr
- uses: peter-evans/create-pull-request@v3
- with:
- path: ${{ env.DESTINATION_REPO_DIR }}
- token: ${{ secrets.GH_TOKEN_NEXTSTRAIN_BOT_REPO }}
- branch: "nextstrain-bot/test-auspice-pr/${{ steps.detect-pr.outputs.pr-number }}"
- commit-message: "[testing only] Upgrade Auspice to ${{ github.sha }}"
- author: 'nextstrain-bot '
- committer: 'nextstrain-bot '
+ working-directory: ${{ env.DESTINATION_REPO_DIR }}
+ env:
+ GITHUB_TOKEN: ${{ secrets.GH_TOKEN_NEXTSTRAIN_BOT_REPO }}
title: '[bot] [DO NOT MERGE] Test Auspice PR ${{ steps.detect-pr.outputs.pr-number }}'
body: |
This PR has been created to test this project running Auspice with changes from https://github.com/nextstrain/auspice/pull/${{ steps.detect-pr.outputs.pr-number }}.
@@ -81,10 +81,17 @@ jobs:
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).
This message and corresponding commits were automatically created by a GitHub Action from [nextstrain/auspice](https://github.com/nextstrain/auspice).
- draft: true
- delete-branch: true
-
- - name: Check outputs
+ body_file: pr_body.txt
run: |
- echo "PR number: ${{ steps.cpr.outputs.pull-request-number }}" >> "$GITHUB_STEP_SUMMARY"
- echo "PR URL: ${{ steps.cpr.outputs.pull-request-url }}" >> "$GITHUB_STEP_SUMMARY"
+ branch="nextstrain-bot/test-auspice-pr/${{ steps.detect-pr.outputs.pr-number }}"
+ git switch -c "$branch"
+ git push --force origin HEAD
+ pr_url=$(gh pr list --head "$branch" --json url | jq -r '.[0].url')
+
+ if [ "$pr_url" = "null" ]; then
+ echo "$body" > "$body_file"
+ pr_url="$(gh pr create --title "$title" --body-file "$body_file" --draft)"
+ echo "Pull request created: $pr_url" >> "$GITHUB_STEP_SUMMARY"
+ else
+ echo "Pull request updated: $pr_url" >> "$GITHUB_STEP_SUMMARY"
+ fi