-
Notifications
You must be signed in to change notification settings - Fork 34
42 lines (31 loc) · 1.08 KB
/
on-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
name: Create shortened tags
# Only triggered on git tag push
on:
push:
tags: [ '*' ]
jobs:
shorten:
name: Short tags
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Make sure that current tag is merged to master
run: |
cd "$GITHUB_WORKSPACE"
git switch master
# Returns 1 if it's not, and therefore terminates the workflow
git merge-base --is-ancestor "$GITHUB_SHA" HEAD
- name: Create, or update the short-name branch
run: |
cd "$GITHUB_WORKSPACE"
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
TAG=$(echo "$GITHUB_REF" | awk -F/ '{print $NF}')
SHORT=$(echo "${TAG#v}" | cut -d. -f-2)
# Do nothing on test tags
if [[ "$SHORT" = "0.0" ]]; then
exit 0
fi
git branch -f "$SHORT" "$TAG"
REMOTE="https://$GITHUB_ACTOR:${{ secrets.GITHUB_TOKEN }}@github.com/$GITHUB_REPOSITORY.git"
git push --force "$REMOTE" "$SHORT"