-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Support recreating PRs with simple comments (#48)
* new workflow * diff * bash shell * cancel in progress * add log * remove it flag * sed help * gha safe * go back one commit to test * config * small name change * further simplification * create output * generation * base * generation flow * improvement * another improvement * generation improvements * remove pr trigger * generate slates too * recreate on recreate
- Loading branch information
1 parent
ca13baf
commit 0fdc785
Showing
2 changed files
with
77 additions
and
2 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
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 |
---|---|---|
@@ -0,0 +1,59 @@ | ||
name: pr-comment-handler | ||
|
||
on: | ||
issue_comment: | ||
types: [created, edited] | ||
|
||
permissions: | ||
contents: write | ||
pull-requests: write | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
jobs: | ||
|
||
handle-comment: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.issue.pull_request && contains(github.event.comment.body, 'recreate-me') }} | ||
outputs: | ||
pr-head: ${{ steps.pr-details.outputs.head }} | ||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Determine PR details | ||
id: pr-details | ||
run: | | ||
details=$(gh pr view ${{ github.event.issue.number }} --json 'baseRefName,headRefName' 2>&1) | ||
headRefName=$(printf '%s' "$details" | jq -rc '.headRefName') | ||
baseRefName=$(printf '%s' "$details" | jq -rc '.baseRefName') | ||
if [[ "$headRefName" = "null" ]] || [[ "$baseRefName" = "null" ]]; then | ||
echo "::error::Failed to parse pr details" | ||
echo "$details" | ||
exit 1 | ||
fi | ||
echo "head=$headRefName" | tee -a "$GITHUB_OUTPUT" | ||
echo "base=$baseRefName" | tee -a "$GITHUB_OUTPUT" | ||
create-new: | ||
needs: [handle-comment] | ||
uses: ./.github/workflows/generate.yml | ||
with: | ||
pr-base: ${{ needs.handle-comment.outputs.pr-head }} | ||
secrets: inherit | ||
|
||
close-old: | ||
needs: [handle-comment, create-new] | ||
runs-on: ubuntu-latest | ||
steps: | ||
|
||
- uses: actions/checkout@v4 | ||
|
||
- name: Close old PR | ||
run: | | ||
gh pr close ${{ github.event.issue.number }} \ | ||
-c "Re-created as #${{ needs.create-new.outputs.pr-number }}" |