Skip to content

Commit dbe3429

Browse files
authored
Change the workflow for opening upstream PRs to post links that open PRs (#157)
* Add GH auth token to env * Make the job post a comment with a link to open the PR instead of actually opening the PR
1 parent a07abe2 commit dbe3429

File tree

1 file changed

+12
-16
lines changed

1 file changed

+12
-16
lines changed

.github/workflows/rocm-open-upstream-pr.yml

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,8 @@ jobs:
1010
contents: write
1111
pull-requests: write
1212
runs-on: ubuntu-latest
13-
outputs:
14-
new-pr-link: ${{ steps.create-pr.outputs.link }}
1513
env:
1614
NEW_BRANCH_NAME: "${{ github.head_ref }}-upstream"
17-
NEW_PR_TITLE: "[ROCM] ${{ github.event.pull_request.title }}"
1815
steps:
1916
- name: Checkout code
2017
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
@@ -24,19 +21,18 @@ jobs:
2421
git checkout -b $NEW_BRANCH_NAME origin/${{ github.head_ref }}
2522
git rebase --onto origin/main
2623
git push origin HEAD
27-
# TODO: Change the base of the PR to upstream main
28-
- name: Create a PR to upstream
29-
id: create-pr
30-
run: |
31-
echo link=$(gh pr create --repo rocm/jax --base main --head $NEW_BRANCH_NAME --title "$NEW_PR_TITLE" --body "${{ github.event.pull_request.body }}") >> "$GITHUB_OUTPUT"
32-
comment-link:
33-
needs: open-upstream
34-
permissions:
35-
pull-requests: write
36-
runs-on: ubuntu-latest
37-
steps:
38-
- name: Leave comment on old PR
24+
- name: Leave link to create PR
3925
env:
4026
GH_TOKEN: ${{ github.token }}
41-
run: gh pr comment ${{ github.event.pull_request.number }} --repo rocm/jax --body ${{ needs.open-upstream.outputs.new-pr-link.link }}
27+
run: |
28+
# Bash is not friendly with newline characters, so make our own
29+
NL=$'\n'
30+
# Encode the PR title and body for passing as URL get parameters
31+
TITLE_ENC=$(jq -rn --arg x "[ROCm] ${{ github.event.pull_request.title }}" '$x|@uri')
32+
BODY_ENC=$(jq -rn --arg x $"${{ github.event.pull_request.body }}${NL}${NL}Created from: ${{ github.event.pull_request.url }}" '$x|@uri')
33+
# Create a link to the that will open up a new PR form to upstream and autofill the fields
34+
CREATE_PR_LINK="https://github.com/jax-ml/jax/compare/main...ROCm:jax:$NEW_BRANCH_NAME?expand=1&title=$TITLE_ENC&body=$BODY_ENC"
35+
# Add a comment with the link to the PR
36+
COMMENT_BODY="Feature branch from main is ready. [Create a new PR]($CREATE_PR_LINK) destined for upstream?"
37+
gh pr comment ${{ github.event.pull_request.number }} --repo rocm/jax --body "$COMMENT_BODY"
4238

0 commit comments

Comments
 (0)