Automatically update the latest tag to the HEAD on master. #3
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 | |
jobs: | |
update: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create latest | |
run: | | |
with: | |
script: | | |
# Deletion no-ops if it's not already there. | |
github.rest.git.deleteRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'tags/latest', | |
sha: context.sha | |
}).catch(err => { | |
# We use create rather than update, because this ensures that the | |
# 'latest' tag is actually pushed to trigger the publication job. | |
github.rest.git.createRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: 'refs/tags/latest', | |
sha: context.sha | |
}); | |
}) | |