Skip to content

Commit ea7683f

Browse files
authored
Add GHA workflow for opening PRs upstream (#116)
* Add file for opening PRs upstream * Add HEAD_REF as environment variable * Fill out code for making a new branch and opening a PR to upstream * Add names for steps * Fix yaml * Fix yaml again * Leave a comment on the old PR linking to the new one * Add proper permissions for creating banches and opening PRs * Fix YAML
1 parent 650e70a commit ea7683f

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: ROCm Open Upstream PR
2+
on:
3+
pull_request:
4+
types: [ labeled ]
5+
branches: [ rocm-main ]
6+
jobs:
7+
open-upstream:
8+
if: ${{ github.event.label.name == 'open-upstream' }}
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
runs-on: ubuntu-latest
13+
outputs:
14+
new-pr-link: ${{ steps.create-pr.outputs.link }}
15+
env:
16+
NEW_BRANCH_NAME: "${{ github.head_ref }}-upstream"
17+
NEW_PR_TITLE: "[ROCM] ${{ github.event.pull_request.title }}"
18+
steps:
19+
- name: Checkout code
20+
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
21+
- name: Rebase code to main
22+
run: |
23+
git checkout -b $NEW_BRANCH_NAME ${{ github.head_ref }}
24+
git rebase --onto main
25+
git push origin HEAD
26+
# TODO: Change the base of the PR to upstream main
27+
- name: Create a PR to upstream
28+
id: create-pr
29+
run: |
30+
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"
31+
comment-link:
32+
needs: open-upstream
33+
permissions:
34+
pull-requests: write
35+
runs-on: ubuntu-latest
36+
steps:
37+
- name: Leave comment on old PR
38+
run: gh pr comment ${{ github.event.pull_request.number }} --repo rocm/jax --body ${{ needs.open-upstream.outputs.new-pr-link.link }}
39+

0 commit comments

Comments
 (0)