Automatically update the latest tag to the HEAD on master. #5
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 latest tag | |
on: | |
push: | |
branches: | |
- master | |
paths: | |
- '**.go' | |
- 'go.**' | |
- .github/workflows/update-tag.yaml | |
permissions: | |
contents: write | |
# We delete and re-create the tag to ensure that there's actually a push to | |
# trigger the publication action, rather than using the updateRef function. | |
# The deletion itself no-ops if it's not already there. | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create latest | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
github.rest.git.deleteRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'tags/latest', | |
sha: context.sha | |
}).catch(err => { | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/latest', | |
sha: context.sha | |
}); | |
}) | |