-
Notifications
You must be signed in to change notification settings - Fork 0
47 lines (42 loc) · 1.13 KB
/
retag.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
name: recreate major and minor tags
on:
push:
tags: v*.*.*
jobs:
retag:
runs-on: ubuntu-latest
- name: Recreate Major and Minor Tags
uses: actions/github-script@v5
with:
script: |
const {
ref,
repo: {
owner,
repo,
},
sha,
} = context;
const tagMatch = ref.match(/^((v[0-9]+)\.[0-9]+)\.[0-9]+$/);
if (tagMatch !== null) {
const [, major, minor] = tagMatch;
for (const tag of [major, minor]) {
const tagRef = 'refs/tags/' + tag;
github.rest.git.createRef({
owner,
repo,
ref: tagRef,
sha,
}).catch(err => {
if (err.status !== 422) {
throw err;
}
github.rest.git.updateRef({
owner,
repo,
ref: tagRef,
sha,
});
});
}
}