Update README.md on tag creation #23
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: Update README.md on tag creation | |
on: | |
create: | |
jobs: | |
build: | |
if: startsWith(github.ref, 'refs/tags/') | |
runs-on: ubuntu-latest | |
permissions: | |
contents: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Delete tag from remote and local | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
echo "Tag ${{ github.ref }} was created. Deleting tag '$VERSION' from remote and local. " | |
git tag -d $VERSION | |
git push --delete origin $VERSION | |
- name: Update README.md and push with version tag | |
run: | | |
VERSION=${GITHUB_REF#refs/tags/} | |
echo "Tagging updated README.md with '$VERSION'." | |
sed "s/readme-\(.*\)-blue/readme-$VERSION-blue/g" README.md > temp.md | |
mv temp.md README.md | |
git config --local user.email "actions@github.com" | |
git config --local user.name "GitHub Actions" | |
git add README.md | |
git commit -m "Update README.md for tag '$VERSION' [skip ci]" | |
git tag $VERSION | |
git push origin HEAD:main | |
git push origin $VERSION | |
echo "Pushed updated README.md with tag '$VERSION' to remote." |