Skip to content

Sync with Upstream (merge) #107

Sync with Upstream (merge)

Sync with Upstream (merge) #107

name: Sync with Upstream (merge)
on:
pull_request_review:
types: [edited, submitted]
permissions:
contents: write
pull-requests: write
id-token: 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: Retrieve secrets
uses: grafana/shared-workflows/actions/get-vault-secrets@main
with:
repo_secrets: |
APP_ID=app:id
APP_PRIVATE_KEY=app:private-key
- name: Generate a token
id: generate-token
uses: actions/create-github-app-token@5d869da34e18e7287c1daad50e0b8ea0f506ce69 # v1.11.0
with:
app-id: ${{ env.APP_ID }}
private-key: ${{ env.APP_PRIVATE_KEY }}
- name: Checkout the repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4.1.7
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
token: ${{ steps.generate-token.outputs.token }}
- 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 }}
```'