Updated npm version of package, described changes in CHANGELOG.md #69
Workflow file for this run
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 gitlab-main to main | |
| on: | |
| push: | |
| branches: | |
| - gitlab-main | |
| jobs: | |
| pr-and-merge: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v3 | |
| - name: Authenticate GitHub CLI | |
| run: gh auth setup-git | |
| env: | |
| GH_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} | |
| - name: Check or create PR | |
| id: pr | |
| env: | |
| GH_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} | |
| run: | | |
| set -e | |
| pr_number=$(gh pr list --head gitlab-main --base main --state open --json number -q '.[0].number') | |
| if [ -z "$pr_number" ]; then | |
| echo "No PR found. Creating new PR..." | |
| gh pr create \ | |
| --head gitlab-main \ | |
| --base main \ | |
| --title "Sync gitlab-main to main" \ | |
| --body "Automated PR from GitLab CI via gh CLI" \ | |
| --label auto-merge | |
| # PR is just created; get number again | |
| pr_number=$(gh pr list --head gitlab-main --base main --state open --json number -q '.[0].number') | |
| else | |
| echo "PR already exists with number: $pr_number" | |
| fi | |
| echo "pr_number=$pr_number" >> "$GITHUB_OUTPUT" | |
| - name: Approve PR | |
| id: pr_approve | |
| env: | |
| GH_TOKEN: ${{ secrets.AUTOAPPROVE_TOKEN }} | |
| run: | | |
| PR_NUMBER="${{ steps.pr.outputs.pr_number }}" | |
| gh pr review "$PR_NUMBER" --approve | |
| echo "merge_approved=true" >> "$GITHUB_OUTPUT" | |
| - name: Merge PR | |
| id: pr_merge | |
| if: steps.pr_approve.outputs.merge_approved == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} | |
| run: | | |
| PR_NUMBER="${{ steps.pr.outputs.pr_number }}" | |
| gh pr merge "$PR_NUMBER" --merge --admin | |
| echo "merge_succeeded=true" >> "$GITHUB_OUTPUT" | |
| - name: Delete branch | |
| if: steps.pr_merge.outputs.merge_succeeded == 'true' | |
| env: | |
| GH_TOKEN: ${{ secrets.AUTOMERGE_TOKEN }} | |
| run: | | |
| echo "Deleting remote branch 'gitlab-main'" | |
| gh auth setup-git | |
| git push origin --delete gitlab-main | |
| echo "branch_deleted=true" >> "$GITHUB_OUTPUT" |