Skip to content

Manual create release pr #4

Manual create release pr

Manual create release pr #4

name: Manual create release pr
on:
workflow_dispatch:
jobs:
create-release-pr:
if: github.event.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.RENOVATE_GITHUB_TOKEN }}
- name: Set up Git and import GPG key
env:
GPG_PRIVATE_KEY: ${{ secrets.RENOVATE_PRIVATE_KEY }}
run: |
echo "${GPG_PRIVATE_KEY}" | gpg --import
git config user.name "CCBC Service Account"
git config user.email "[email protected]"
git config user.signingkey "$(gpg --list-secret-keys --with-colons | awk -F: '/sec:/ {print $5}')"
git config commit.gpgsign true
- name: dev env setup
uses: ./.github/actions/dev-env-setup
- name: Delete Latest Tag If It Already Exists
run: |
git checkout main
yarn
NEW_TAG=$(yarn release-it --release-version | awk 'match($0, /^ *([0-9]+\.[0-9]+\.[0-9]+)/, a) { if (NR == 1) next; print "v" a[1]; exit; }')
TAG_EXISTS=$(git tag -l $NEW_TAG)
echo $NEW_TAG
if [ "$TAG_EXISTS" ]; then
git tag -d $NEW_TAG
git push --delete origin $NEW_TAG
fi
- name: Delete and Recreate Branch
run: |
git branch -D chore/release || true
git push origin --delete chore/release || true
git checkout main
git checkout -b chore/release
- name: Close Previous PRs
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo
const prs = await github.rest.pulls.list({ owner, repo, state: 'open', head: 'bcgov:chore/release' })
for (const pr of prs.data) {
await github.rest.pulls.update({ owner, repo, pull_number: pr.number, state: 'closed' })
}
- name: Setup Sqitch User
run: |
sqitch config --user user.name 'CCBC Service Account'
sqitch config --user user.email '[email protected]'
- name: Make Release
run: |
git checkout chore/release
git push --set-upstream origin chore/release
git pull
echo '--ci' | make release
- name: Create PR
uses: actions/github-script@v7
with:
github-token: ${{ secrets.RENOVATE_GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo
await github.rest.pulls.create({
owner,
repo,
title: 'chore: release',
head: 'chore/release',
base: 'main',
});