🔄 Merge Dev → Main after Store PR Merge #22
This file contains hidden or 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: 🔄 Merge Dev → Main after Store PR Merge | |
| on: | |
| schedule: | |
| - cron: "*/2 * * * *" # check every 15 minutes | |
| workflow_dispatch: # manual trigger | |
| jobs: | |
| merge-dev-if-pr-merged: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: 🔎 Check latest PR from fork | |
| id: pr | |
| env: | |
| GH_TOKEN: ${{ secrets.FORK_PAT }} | |
| run: | | |
| # Get the latest PR from your fork branch auto-update-nebula | |
| pr=$(gh pr list \ | |
| --repo sineorg/store \ | |
| --state all \ | |
| --head JustAdumbPrsn:auto-update-nebula \ | |
| --limit 1 \ | |
| --json number,state,mergedAt \ | |
| --jq '.[0]') | |
| if [ "$pr" = "null" ] || [ -z "$pr" ]; then | |
| echo "No PR found from fork branch" | |
| echo "found=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| state=$(echo "$pr" | jq -r '.state') | |
| mergedAt=$(echo "$pr" | jq -r '.mergedAt') | |
| echo "PR state: $state" | |
| echo "PR merged at: $mergedAt" | |
| if [ "$state" != "MERGED" ]; then | |
| echo "PR not merged yet. Exiting." | |
| echo "found=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo "found=true" >> $GITHUB_OUTPUT | |
| - name: 📥 Checkout Zen-Nebula | |
| if: steps.pr.outputs.found == 'true' | |
| uses: actions/checkout@v4 | |
| - name: ⚙️ Setup Git | |
| if: steps.pr.outputs.found == 'true' | |
| run: | | |
| git config --global user.name "github-actions[bot]" | |
| git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: 🔄 Merge Dev into Main | |
| if: steps.pr.outputs.found == 'true' | |
| run: | | |
| git fetch origin | |
| git checkout main | |
| git merge origin/Dev --no-edit || true | |
| git push origin main |