diff --git a/.github/workflows/update-badge.yml b/.github/workflows/update-badge.yml index 6bad3f3..6fb55c1 100644 --- a/.github/workflows/update-badge.yml +++ b/.github/workflows/update-badge.yml @@ -10,23 +10,29 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 + - 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: 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\\](.*)|![Version Badge](${BADGE_URL})|" README.md - - - name: Commit and push changes - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git add README.md - git commit -m "Update version badge to $TAG" - git push + - 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\\](.*)|![Version Badge](${BADGE_URL})|" 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 origin HEAD:main # push changes to the same branch diff --git a/.github/workflows/update-version.yml b/.github/workflows/update-version.yml index 3e4f993..e7db475 100644 --- a/.github/workflows/update-version.yml +++ b/.github/workflows/update-version.yml @@ -10,22 +10,28 @@ jobs: runs-on: ubuntu-latest steps: - - name: Checkout repository - uses: actions/checkout@v2 + - 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: Get the latest tag + id: get_tag + run: echo ::set-output name=tag::${GITHUB_REF#refs/tags/} - - name: Update version in HTML - run: | - TAG=${{ steps.get_tag.outputs.tag }} - sed -i "s/VERSION_PLACEHOLDER/$TAG/" index.html - - - name: Commit and push changes - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'github-actions[bot]@users.noreply.github.com' - git add index.html - git commit -m "Update version to $TAG" - git push + - name: Update version in HTML + run: | + TAG=${{ steps.get_tag.outputs.tag }} + sed -i "s/VERSION_PLACEHOLDER/$TAG/" index.html + + - 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 index.html + git commit -m "Update version to ${{ steps.get_tag.outputs.tag }}" + git push origin HEAD:main # push changes to the same branch