-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
80 lines (73 loc) · 2.2 KB
/
action.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
name: 'Tag XYZ'
author: 'Kaijie Yu'
description: 'Create a new tag (x.y.z) based on the last one, and dispatch a relevant workflow if needed.'
branding:
icon: 'tag'
color: 'orange'
inputs:
version_level:
description: |
The version level of 'x.y.z', default: 'z'.
required: false
default: 'z'
dispatch_workflow_id:
description:
ID of the workflow to dispatch, e.g., 'test_workflow.yml'.
required: false
default: ''
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Bump New Version
id: bump-version
env:
VERSION_LEVEL: ${{ inputs.version_level }}
shell: bash
run: $GITHUB_ACTION_PATH/bump_version.sh "$VERSION_LEVEL"
- name: Close PR for Issue ${{ github.event.issue.number }}
env:
OLD_VERSION: ${{ steps.bump-version.outputs.old_version }}
VERSION: ${{ steps.bump-version.outputs.version }}
shell: bash
run: |
echo "### Version: $OLD_VERSION to $VERSION" >> $GITHUB_STEP_SUMMARY
- name: Create Tag
uses: actions/github-script@v7
env:
VERSION: ${{ steps.bump-version.outputs.version }}
with:
script: |
try {
await github.rest.git.createRef({
owner: context.repo.owner,
repo: context.repo.repo,
ref: "refs/tags/${{ env.VERSION }}",
sha: context.sha
})
} catch(error) {
console.error(error)
core.setFailed(error)
}
- name: Dispatch Workflow
if: inputs.dispatch_workflow_id != ''
uses: actions/github-script@v7
env:
WORKFLOW_ID: ${{ inputs.dispatch_workflow_id }}
VERSION: ${{ steps.bump-version.outputs.version }}
with:
script: |
try {
await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: "${{ env.WORKFLOW_ID }}",
ref: "refs/tags/${{ env.VERSION }}"
})
} catch(error) {
console.error(error)
core.setFailed(error)
}