Skip to content

Tagging

Tagging #29

Workflow file for this run

name: Tagging
on:
workflow_run:
workflows:
- CI
branches:
- main
types:
- completed
workflow_dispatch:
jobs:
tagging:
runs-on: ubuntu-latest
if: ${{ contains(github.ref, 'main') }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Set Tag Value
run: |
echo "DATE=v$(echo `date +'%Y.%m'`)" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v7
if: ${{ env.DATE }}
with:
github-token: ${{ github.token }}
script: |
let tagExists = [];
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.DATE }}",
sha: context.sha
});
} catch (e) {
console.log("Tag already exists: " + e)
tagExists.push(e);
}
if (tagExists.length > 0) {
await github.rest.git.updateRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "tags/${{ env.DATE }}",
sha: context.sha
});
}