Skip to content

Commit

Permalink
Update update-latest-tag.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
ronny-antoon committed Nov 15, 2023
1 parent e78def5 commit 7c3a864
Showing 1 changed file with 18 additions and 25 deletions.
43 changes: 18 additions & 25 deletions .github/workflows/update-latest-tag.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,30 +9,23 @@ on:
jobs:
update-latest-tag:
runs-on: ubuntu-latest
if: github.event.release.tag_name != 'latest'

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up Git
run: |
git config user.name "${{ github.actor }}"
git config user.email "${{ github.actor }}@users.noreply.github.com"
- name: Remove "latest" tag
env:
GH_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} # Set the GH_TOKEN environment variable
run: |
latest_tag_id=$(gh tag list | grep "latest" | awk '{print $1}')
if [ -n "$latest_tag_id" ]; then
gh tag delete $latest_tag_id --yes
fi
- name: Create new "latest" tag
env:
GH_TOKEN: ${{ secrets.MY_GITHUB_TOKEN }} # Set the GH_TOKEN environment variable

run: |
gh repo create-tag latest -m "Tag description"
- name: Check if release tag is not 'latest'
run: |
if [[ "${{ github.event.release.tag_name }}" != 'latest' ]]; then
echo "Release tag is not 'latest'."
else
echo "Release tag is 'latest'. Exiting workflow."
exit 78
fi
- name: Remove existing 'latest' tag
run: |
git tag -d latest || true
git push origin :refs/tags/latest || true
- name: Create new 'latest' tag
run: |
git tag latest
git push origin latest

0 comments on commit 7c3a864

Please sign in to comment.