-
Notifications
You must be signed in to change notification settings - Fork 1
66 lines (58 loc) · 1.93 KB
/
update-latest.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
62
63
64
65
66
name: Update latest
on:
workflow_dispatch:
workflow_run:
workflows:
- Base Image
types:
- completed
jobs:
update-latest:
name: Rebuild release images
runs-on: ubuntu-latest
steps:
- name: Find latest tag
uses: actions/github-script@v7
with:
# need different token, RELEASE_TOKEN belongs to digineobot
github-token: ${{ secrets.RELEASE_TOKEN }}
script: |
const { owner, repo } = context.repo
const { data: allTags } = await github.rest.git.listMatchingRefs({
owner,
repo,
ref: 'tags/v',
})
const { ref, object: { sha: releaseRef } } = allTags[allTags.length - 1],
releaseTag = ref.substring(10)
console.log(`latest release: ${releaseTag}, ${releaseRef}`)
const { data: { object: { sha: masterRef } } } = await github.rest.git.getRef({
owner,
repo,
ref: 'heads/master',
})
console.log(`master release commit: ${masterRef}`)
await github.rest.actions.createWorkflowDispatch({
owner,
repo,
workflow_id: 'release.yml',
ref: releaseTag,
inputs: {
goreleaser: false,
releaseType: 'release',
}
})
console.log(`triggered release for ${releaseTag} (${releaseRef})`)
if (releaseRef !== masterRef) {
await github.rest.actions.createWorkflowDispatch({
owner,
repo,
workflow_id: 'release.yml',
ref: 'master',
inputs: {
goreleaser: false,
releaseType: 'dev',
}
})
console.log(`triggered dev-release for master (${masterRef})`)
}