Skip to content

chore: enable workflow dispatch for auto-release-pr #12

chore: enable workflow dispatch for auto-release-pr

chore: enable workflow dispatch for auto-release-pr #12

name: Auto release PR
on:
push:
branches:
- main
- staging
workflow_dispatch:
permissions:
contents: write # to create release
pull-requests: write # to create release PR
jobs:
# from https://github.com/peter-evans/create-pull-request/blob/main/docs/examples.md#keep-a-branch-up-to-date-with-another
productionRelease:
if: github.ref == 'refs/heads/staging'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: production
- name: Fetch all tags
run: git fetch --tags
- name: Get latest tag
id: get_latest_tag
run: echo "::set-output name=tag::$(git describe --tags `git rev-list --tags --max-count=1`)"
- name: Checkout latest tag
run: git checkout ${{ steps.get_latest_tag.outputs.tag }}
- name: Force update production branch to latest tag
run: |
git checkout production
git reset --hard ${{ steps.get_latest_tag.outputs.tag }}
git push origin production --force
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7.0.5
with:
branch: production-release
title: 'chore: Point production to latest tag'
body: 'This PR points the production branch to the latest tag.'
stagingRelease:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: staging
- name: Fetch all tags
run: git fetch --tags
- name: Get latest tag
id: get_latest_tag
run: echo "::set-output name=tag::$(git describe --tags `git rev-list --tags --max-count=1`)"
- name: Checkout latest tag
run: git checkout ${{ steps.get_latest_tag.outputs.tag }}
- name: Force update staging branch to latest tag
run: |
git checkout staging
git reset --hard ${{ steps.get_latest_tag.outputs.tag }}
git push origin staging --force
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7.0.5
with:
branch: staging-release
title: 'chore: point staging to latest release tag'
body: 'This PR points the staging branch to the latest release tag.'