Auto PR: Merge dev into master #26
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: Auto Merge Dev to Master | |
| on: | |
| # schedule: | |
| # - cron: "0 * * * *" # Runs every hour | |
| workflow_dispatch: # Allows manual trigger | |
| pull_request: | |
| branches: | |
| - master | |
| types: | |
| - opened | |
| - synchronize | |
| jobs: | |
| auto-merge: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@v3 | |
| - name: Install GitHub CLI | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y gh | |
| - name: Find and Merge Pull Requests | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| run: | | |
| # Configure `gh` CLI to use GITHUB_TOKEN directly | |
| gh auth status || echo "Using GITHUB_TOKEN for authentication." | |
| # Fetch PRs from `dev` to `master` | |
| PRS=$(gh pr list --base master --head dev --state open --json number,mergeable -q '.[] | select(.mergeable == true) | .number') | |
| echo "Found PRs: $PRS" | |
| for PR in $PRS; do | |
| echo "Merging PR #$PR" | |
| gh pr merge $PR --merge --admin | |
| done |