Skip to content
This repository has been archived by the owner on Jun 20, 2024. It is now read-only.

Tagging

Tagging #75

Workflow file for this run

name: Tagging
on:
workflow_run:
workflows:
- CI
types:
- completed
branches:
- main
paths:
- "deployment/*"
workflow_dispatch:
env:
COMMIT_MSG: ${{ github.event.head_commit.message }}
jobs:
tagging:
runs-on: ubuntu-latest
if: ${{ contains(github.ref, 'main') }}
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Fetch remote tags
run: git fetch origin +refs/tags/*:refs/tags/*
- name: Set Tag Value
run: |
echo "DATE=v$(echo `date +'%Y.%m'`)" >> $GITHUB_ENV
echo "CHANGELOG=`git log --oneline $(git describe --tags @ --abbrev=0 @^ | head -n 1)..@`" >> $GITHUB_ENV
- name: Create Tag
uses: actions/github-script@v7
if: ${{ env.DATE }}
with:
github-token: ${{ github.token }}
script: |
let tagExists = [];
const commit = await github.rest.repos.getCommit({
owner: context.repo.owner,
repo: context.repo.repo,
ref: 'main'
});
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.DATE }}",
message: "${{ env.CHANGELOG }}",
sha: commit.data.sha.toString()
});
} 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: commit.data.sha.toString(),
message: "${{ env.CHANGELOG }}",
force: true
});
}