Skip to content

fix: use gh token instead of pat for auto approve (#627) #8

fix: use gh token instead of pat for auto approve (#627)

fix: use gh token instead of pat for auto approve (#627) #8

name: Sync
on:
push:
branches:
- prod
jobs:
branch-sync:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: master
- name: Reset sync branch
run: |
git fetch origin prod:prod
git reset --hard prod
- name: Create Pull Request
id: cpr
uses: peter-evans/create-pull-request@v6
with:
token: ${{ secrets.MY_GITHUB_TOKEN }}
branch: prod-sync
base: master
title: "Sync changes from prod to master"
body: "This PR is automatically generated to sync changes from prod to master."
labels: "sync,automated pr"
- name: Enable Pull Request Automerge
if: steps.cpr.outputs.pull-request-operation == 'created'
uses: peter-evans/enable-pull-request-automerge@v3
with:
token: ${{ secrets.MY_GITHUB_TOKEN }}
pull-request-number: ${{ steps.cpr.outputs.pull-request-number }}
merge-method: merge
- name: Auto approve
if: steps.cpr.outputs.pull-request-operation == 'created'
run: gh pr review --approve "${{ steps.cpr.outputs.pull-request-number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}