Schedule merge from develop into main #26
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: Schedule merge from develop into main | |
on: | |
schedule: | |
- cron: "0 12 * * 0" # Every Sunday at 21:00 JST | |
workflow_dispatch: | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
merge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
ref: develop | |
- name: Diff develop and main | |
id: diff | |
run: git diff origin/main origin/develop --exit-code | |
continue-on-error: true | |
- name: Create a PR | |
id: pull-request | |
# If diff is exist, create a PR | |
if: ${{ steps.diff.outcome == 'failure' }} | |
run: | | |
PR_URL=$(gh pr create -B main -t "release(prod): weekly merge from develop into main" -l 'Type: Release' -b "Regular merge every Sunday at 21:00 JST.") | |
echo "PR_URL=$PR_URL" >> "$GITHUB_OUTPUT" | |
env: | |
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Approve a PR | |
# Only approve if PR has diff | |
if: ${{ steps.diff.outcome == 'failure' }} | |
run: gh pr review --approve "$PR_URL" | |
env: | |
PR_URL: ${{ steps.pull-request.outputs.PR_URL }} | |
GH_TOKEN: ${{ secrets.IPUTAPP_BOT_PAT_APPROVE }} | |
- name: Enable auto-merge for PRs | |
# Only merge if PR has diff | |
if: ${{ steps.diff.outcome == 'failure' }} | |
run: gh pr merge --auto --merge "$PR_URL" | |
env: | |
PR_URL: ${{ steps.pull-request.outputs.PR_URL }} | |
GH_TOKEN: ${{ secrets.IPUTAPP_BOT_PAT_APPROVE }} |