Download Button Action #2
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: "Download Button Action" | |
on: | |
release: | |
types: | |
- published | |
workflow_dispatch: | |
jobs: | |
release: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Get latest release | |
id: get-latest-release | |
uses: InsonusK/[email protected] | |
with: | |
myToken: ${{ github.token }} | |
view_top: 1 | |
- name: Readme Download Button Action | |
env: | |
GITHUB_USER: "MikiMirai" | |
REPO: "Cubith" | |
FORMAT: "zip" | |
VERSION: "${{ steps.get-latest-release.outputs.tag_name }}" | |
COLOR: "blue" | |
BEGIN_TAG: "<!-- BEGIN LATEST DOWNLOAD BUTTON -->" | |
END_TAG: "<!-- END LATEST DOWNLOAD BUTTON -->" | |
run: | | |
UPDATE=$(cat README.md | perl -0777 -pe 's#(${{ env.BEGIN_TAG }})(?:.|\n)*?(${{ env.END_TAG }})#${1}\n[![Download ${{ env.FORMAT }}](https://custom-icon-badges.demolab.com/badge/-Download-${{ env.COLOR }}?style=for-the-badge&logo=download&logoColor=white "Download ${{ env.FORMAT }}")](https://github.com/${{ env.GITHUB_USER }}/${{ env.REPO }}/archive/${{ env.VERSION }}.${{ env.FORMAT }})\n${2}#g') | |
echo "${UPDATE}" > README.md | |
- uses: EndBug/add-and-commit@v7 | |
with: | |
message: "docs(readme): Bump download button version to ${{ steps.get-latest-release.outputs.tag_name }}" | |
default_author: github_actions | |
branch: main |