On PR approval, merge if release branch, otherwise increment alpha version #18
Workflow file for this run
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: "On PR approval, merge if release branch, otherwise increment alpha version" | |
on: | |
pull_request_review: | |
types: [submitted] | |
jobs: | |
alpha: | |
if: github.event.review.state == 'approved' && !(startsWith(github.event.pull_request.head.ref, 'release/')) | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
repository: ${{ github.event.pull_request.head.repo.full_name }} | |
ref: ${{ github.event.pull_request.head.ref }} | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '18.x' | |
registry-url: 'https://registry.npmjs.org' | |
- name: Configure git identity | |
run: | | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
git config --global user.name "Userfront Robot" | |
- name: Increment alpha version | |
id: version | |
run: | | |
npm version prerelease --preid alpha -w package | sed -n '2p' | xargs -0 -L1 -I '%' echo "VERSION=%" >> "$GITHUB_OUTPUT" | |
- name: commit changes | |
run: | | |
git add . && git commit -m "Update to ${{ steps.version.outputs.VERSION }}" | |
- name: push changes | |
run: | | |
git push | |
stable: | |
if: github.event.review.state == 'approved' && startsWith(github.event.pull_request.head.ref, 'release/') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.pulls.merge({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
pull_number: ${{ github.event.pull_request.number }}, | |
merge_method: 'merge' | |
}) |