-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (61 loc) · 2.2 KB
/
sync-tag.yaml
File metadata and controls
65 lines (61 loc) · 2.2 KB
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
62
63
64
65
name: Sync Tag
on:
workflow_dispatch:
schedule:
- cron: '0 0 1 * *'
jobs:
sync:
runs-on: ubuntu-latest
outputs:
tagged: ${{ steps.tag.outputs.tagged }}
commit-hash: ${{ steps.tag.outputs.commit-hash }}
tag-name: ${{ steps.tag.outputs.tag-name }}
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-tags: true
- name: Add tag
id: tag
run: |
latest_tag_name=$(wget -qO- -t1 -T2 "https://api.github.com/repos/tailscale/tailscale/releases/latest" | jq -r '.tag_name')
if [ -z "$latest_tag_name" ]; then
echo "fetch tag name failed"
echo "tagged=false" >> $GITHUB_OUTPUT
exit 0
fi
latest_commit_hash=$(wget -qO- -t1 -T2 "https://api.github.com/repos/tailscale/tailscale/commits" | jq -r '.[0].sha')
if [ -z "$latest_commit_hash" ]; then
echo "fetch commit hash failed"
echo "tagged=false" >> $GITHUB_OUTPUT
exit 0
fi
version="${latest_tag_name}-${latest_commit_hash:0:7}"
if git rev-parse "refs/tags/$version" >/dev/null 2>&1; then
echo "tag exists"
echo "tagged=false" >> $GITHUB_OUTPUT
exit 0
fi
git config user.name "GitHub Actions"
git config user.email "github-actions@users.noreply.github.com"
git tag -a $version -m "release $version"
echo "tagged=true" >> $GITHUB_OUTPUT
echo "commit-hash=${latest_commit_hash}" >> $GITHUB_OUTPUT
echo "tag-name=${version}" >> $GITHUB_OUTPUT
echo "tag set"
- name: Push tags
if: steps.tag.outputs.tagged == 'true'
uses: ad-m/github-push-action@master
with:
branch: main
trigger-build:
needs: sync
if: needs.sync.outputs.tagged == 'true'
uses: ./.github/workflows/release-derper.yaml
with:
ref: ${{ needs.sync.outputs.commit-hash }}
release-tag-name: ${{ needs.sync.outputs.tag-name }}
release-image: ${{ vars.DOCKERHUB_REPO }}
secrets:
registry-username: ${{ secrets.DOCKERHUB_USERNAME }}
registry-password: ${{ secrets.DOCKERHUB_TOKEN }}