-
-
Notifications
You must be signed in to change notification settings - Fork 1
61 lines (58 loc) · 1.68 KB
/
tagging.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
name: Tagging
on:
push:
branches:
- main
paths:
- "deployment/*"
workflow_run:
workflows:
- CI
types:
- completed
branches:
- main
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 v2021.08 --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 = [];
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.DATE }}",
message: "${{ env.CHANGELOG }}",
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 }}",
message: "${{ env.CHANGELOG }}",
sha: context.sha
});
}