Skip to content

release-prepare-monthly #41

release-prepare-monthly

release-prepare-monthly #41

name: release-prepare-monthly
on:
schedule:
# Runs at midnight UTC on the 1st of every month
- cron: '0 0 1 * *'
workflow_dispatch:
jobs:
create-release-pr:
runs-on: ubuntu-latest
steps:
- name: Check if running on the original repository
run: |
if [ "$GITHUB_REPOSITORY_OWNER" != "parse-community" ]; then
echo "This is a forked repository. Exiting."
exit 1
fi
- name: Checkout working branch
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Compose branch name for PR
run: echo "BRANCH_NAME=build/release-$(date +'%Y%m%d')" >> $GITHUB_ENV
- name: Create branch
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "GitHub Actions"
git checkout -b ${{ env.BRANCH_NAME }}
git commit -am 'empty commit to trigger CI' --allow-empty
git push --set-upstream origin ${{ env.BRANCH_NAME }}
- name: Create PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
script: |
const { data: pulls } = await github.rest.pulls.list({
owner: context.repo.owner,
repo: context.repo.repo,
head: `${context.repo.owner}:${process.env.BRANCH_NAME}`,
base: 'release',
state: 'open'
});
if (pulls.length > 0) {
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pulls[0].number,
title: 'build: Release',
body: '## Release\n\nThis pull request was created automatically according to the release cycle.\n\n> [!WARNING]\n> Only use `Merge Commit` to merge this pull request. Do not use `Rebase and Merge` or `Squash and Merge`.'
});
} else {
await github.rest.pulls.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'build: Release',
head: process.env.BRANCH_NAME,
base: 'release',
body: '## Release\n\nThis pull request was created automatically according to the release cycle.\n\n> [!WARNING]\n> Only use `Merge Commit` to merge this pull request. Do not use `Rebase and Merge` or `Squash and Merge`.'
});
}
# auto-merge-pr:
# needs: create-release-pr
# runs-on: ubuntu-latest
# steps:
# - name: Wait for CI checks to pass
# uses: hmarr/auto-approve-action@v4
# with:
# github-token: ${{ secrets.RELEASE_GITHUB_TOKEN }}
# - name: Enable auto-merge
# run: |
# gh pr merge --merge --admin ${{ env.BRANCH_NAME }}
# env:
# GITHUB_TOKEN: ${{ secrets.RELEASE_GITHUB_TOKEN }}