Update README #11
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 version badge | |
on: | |
push: | |
tags: | |
- 'v*' | |
jobs: | |
update-badge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 # Fetch all history for all branches and tags | |
- name: Get the latest tag | |
id: get_tag | |
run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/} | |
- name: Update README with version badge | |
run: | | |
TAG=${{ steps.get_tag.outputs.tag }} | |
BADGE_URL="https://img.shields.io/badge/version-${TAG}-brightgreen" | |
sed -i "s|!\\[Version Badge\\](.*)||" README.md | |
- name: Commit and push changes | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
git config --global user.name 'github-actions[bot]' | |
git config --global user.email 'github-actions[bot]@users.noreply.github.com' | |
git fetch origin | |
git checkout -B main origin/main # or the branch you are working on | |
git add README.md | |
git commit -m "Update version badge to ${{ steps.get_tag.outputs.tag }}" | |
git push https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }} HEAD:main # push changes to the same branch |