Skip to content

Instantly share code, notes, and snippets.

@VisualBean
Last active April 10, 2023 11:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save VisualBean/be13555116aa8cb50ab8a7f43e218168 to your computer and use it in GitHub Desktop.
Save VisualBean/be13555116aa8cb50ab8a7f43e218168 to your computer and use it in GitHub Desktop.
name: Release
permissions:
contents: write
on:
workflow_dispatch:
jobs:
prereleaseCheck:
runs-on: ubuntu-latest
name: Check release
steps:
- name: Checkout repository
uses: actions/checkout@v1
- name: Semantic Release
uses: cycjimmy/semantic-release-action@v3
id: semantic
with:
extra_plugins: |
conventional-changelog-conventionalcommits
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Commit changes
if: steps.semantic.outputs.new_release_published == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FILE_TO_COMMIT: CHANGELOG.md
DESTINATION_BRANCH: ${{ github.ref }}
run: |
export MESSAGE="chore: update $FILE_TO_COMMIT"
export SHA=$( git rev-parse $DESTINATION_BRANCH:$FILE_TO_COMMIT )
export CONTENT=$( base64 -i $FILE_TO_COMMIT )
gh api --method PUT /repos/:owner/:repo/contents/$FILE_TO_COMMIT \
--field message="$MESSAGE" \
--field content="$CONTENT" \
--field encoding="base64" \
--field branch="$DESTINATION_BRANCH" \
--field sha="$SHA"
outputs:
trigger_release: ${{ steps.semantic.outputs.new_release_published }}
version: ${{ steps.semantic.outputs.new_release_published == 'true' && steps.semantic.outputs.new_release_version }}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment