8
8
branches : main
9
9
paths-ignore : " docs/**"
10
10
workflow_dispatch :
11
+ inputs :
12
+ branch :
13
+ description : ' Branch name'
14
+ required : true
11
15
12
16
jobs :
13
17
add-tag :
@@ -17,20 +21,40 @@ jobs:
17
21
cancel-in-progress : true
18
22
steps :
19
23
- name : Checkout
24
+ if : github.event_name != 'workflow_dispatch'
20
25
uses : actions/checkout@v4
21
26
with :
22
27
fetch-depth : 0
23
28
ref : ${{ github.event.pull_request.head.ref }}
24
29
token : ${{ github.token }}
30
+
31
+ - name : Checkout
32
+ if : github.event_name == 'workflow_dispatch'
33
+ uses : actions/checkout@v4
34
+ with :
35
+ fetch-depth : 0
36
+ ref : ${{ github.event.inputs.branch }}
37
+ token : ${{ github.token }}
38
+
25
39
- name : Display source branch name
26
- run : echo "Source branch name = ${{ github.event.pull_request.head.ref }}"
27
- - name : Retag source branch HEAD commit for testing
40
+ run : |
41
+ if [ "${{ github.event_name }}" = "pull_request" ]; then
42
+ echo "Source branch name = ${{ github.event.pull_request.head.ref }}"
43
+ else
44
+ echo "Source branch name = ${{ github.event.inputs.branch }}"
45
+ fi
46
+
47
+ - name : Retag source branch HEAD commit
28
48
run : |
29
49
git config user.name 'github-actions'
30
50
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
31
51
git tag --delete latest
32
52
git push --delete origin latest
33
- git tag latest "${{ github.event.pull_request.head.ref }}"
53
+ if [ "${{ github.event_name }}" = "pull_request" ]; then
54
+ git tag latest "${{ github.event.pull_request.head.ref }}"
55
+ else
56
+ git tag latest "${{ github.event.inputs.branch }}"
57
+ fi
34
58
git push origin refs/tags/latest
35
59
36
60
call-test-action :
0 commit comments