Last active
April 10, 2023 11:50
-
-
Save VisualBean/be13555116aa8cb50ab8a7f43e218168 to your computer and use it in GitHub Desktop.
This file contains hidden or 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: 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