Sync with Upstream (merge) #97
Workflow file for this run
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
name: Sync with Upstream (merge) | |
on: | |
pull_request_review: | |
types: [edited, submitted] | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
sync: | |
runs-on: ubuntu-latest | |
if: > | |
startsWith(github.event.pull_request.head.ref, 'sync-upstream-') && | |
github.event.review.state == 'approved' && | |
github.event.review.body == 'bot merge' | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.pull_request.head.ref }} | |
- name: Configure Git | |
run: | | |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --local user.name "github-actions[bot]" | |
- name: Attempt to push changes | |
id: push | |
run: | | |
if ! output=$(git push origin HEAD:main); then | |
echo "output=$output" >> $GITHUB_OUTPUT | |
exit 1 | |
fi | |
- name: Delete branch on success | |
if: ${{ success() }} | |
run: | | |
git push -d origin ${{ github.event.pull_request.head.ref }} | |
- name: Comment error on failure | |
if: ${{ failure() }} | |
env: | |
GH_TOKEN: ${{ github.token }} | |
run: | | |
gh pr comment ${{ github.event.pull_request.number }} --body 'Failed to push changes to main. | |
Output: | |
``` | |
${{ steps.push.outputs.output }} | |
```' |