-
Notifications
You must be signed in to change notification settings - Fork 0
44 lines (38 loc) · 1.33 KB
/
create-tag.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
name: Create tag
on:
workflow_dispatch:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 0 * * *'
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Should it run?
id: skip
run: |
PREVTAGCOMMIT="$(git tag --sort=creatordate | tail -n1 | awk -F'-' '{print $4}')"
CURRENTCOMMIT="$(git rev-parse --short HEAD)"
if [ "$PREVTAGCOMMIT" == "$CURRENTCOMMIT" ]; then
echo "Tags are the same ($PREVTAGCOMMIT != $CURRENTCOMMIT), skipping future steps"
echo "::set-output name=skip::true"
else
echo "Tags are not the same ($PREVTAGCOMMIT != $CURRENTCOMMIT). Continuing."
echo "::set-output name=skip::false"
fi
- name: Set tag
id: create-tag-name
if: steps.skip.outputs.skip == 'false'
run: |
v=${GITHUB_REF##*/}
echo "Version: $v"
echo "::set-output name=tag::$(date '+%F')-$(git rev-parse --short HEAD)"
- name: Tag commit
if: steps.skip.outputs.skip == 'false'
uses: tvdias/[email protected]
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
tag: ${{ steps.create-tag-name.outputs.tag }}