bursed #25
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 Release to Development | |
on: | |
push: | |
branches: | |
- release | |
jobs: | |
sync-to-development: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
- name: Configure Git | |
run: | | |
git config --global user.name 'GitHub Action' | |
git config --global user.email '[email protected]' | |
- name: Fetch and checkout development | |
run: | | |
git fetch origin | |
git checkout development | |
git pull | |
- name: Setup GitHub CLI | |
run: echo "${{ secrets.GITHUB_TOKEN }}" | gh auth login --with-token | |
- name: Sync release to development | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
# Check if a PR already exists to sync release to development | |
PR_EXISTS=$(gh pr list --search "Sync Release to Development in:title" --json title --jq ".[] | select(.title | contains(\"Sync Release to Development\"))") | |
if [[ -z "$PR_EXISTS" ]]; then | |
# If no PR exists, create one | |
git checkout -b sync-release-to-development origin/release | |
git push origin sync-release-to-development | |
gh pr create --base development --head sync-release-to-development --title "Sync Release to Development" --body "This PR is created to integrate all outstanding commits from the release branch into the development branch." | |
git checkout development | |
else | |
# If PR exists, update it with new commits from release | |
git checkout sync-release-to-development | |
git pull origin release --rebase | |
git push origin sync-release-to-development | |
git checkout development | |
fi |