Merge pull request #1148 from macbre/prefixes-update #732
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: Auto-release specific changes | |
on: | |
push: | |
branches: [ master ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
auto-release: | |
runs-on: ubuntu-latest | |
timeout-minutes: 2 | |
env: | |
GIT_USER_NAME: "macbre" | |
GIT_USER_EMAIL: "<[email protected]>" | |
steps: | |
# https://github.com/actions/checkout | |
- name: Cloning ${{ env.GIT_BRANCH }} branch | |
uses: actions/checkout@v4 | |
with: | |
ref: master | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 'latest' | |
cache: 'npm' | |
- run: npm ci | |
# https://github.com/actions/checkout#push-a-commit-using-the-built-in-token | |
- name: Set up git and gh CLI tool | |
run: | | |
echo ${{ secrets.GITHUB_TOKEN }} | gh auth login --with-token | |
gh auth status | |
git config user.name ${GIT_USER_NAME} | |
git config user.email ${GIT_USER_EMAIL} | |
- name: Show the most recent changes | |
run: | | |
git status | |
git log -n 1 | |
# https://docs.github.com/en/actions/learn-github-actions/contexts#github-context | |
- name: Take the latest commit message | |
id: commit-message | |
env: | |
GITHUB_CONTEXT: ${{ toJSON(github) }} | |
run: | | |
# -r output raw strings, not JSON texts; | |
export COMMIT_MESSAGE=$(echo "$GITHUB_CONTEXT" | jq -r .event.head_commit.message | head -n1) | |
set -x | |
echo "::set-output name=commit-message::${COMMIT_MESSAGE}" | |
echo "::notice::Got the commit message: ${COMMIT_MESSAGE}" | |
- name: Automatically create a patch release | |
# e.g. Updating rules/prefixes.json (#416) | |
if: contains( steps.commit-message.outputs.commit-message , 'Updating rules/prefixes.json' ) || contains( steps.commit-message.outputs.commit-message , 'prefixes-update' ) | |
run: | | |
./create-gh-release.sh | |
echo "::notice::A new release has been created - $(npm ls --json | jq .version | sed 's/"//g')" |