Skip to content

Commit aaa1ce7

Browse files
committed
support workflow_dispatch event
1 parent b6b9bb3 commit aaa1ce7

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

.github/workflows/run-test.yml

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
branches: main
99
paths-ignore: "docs/**"
1010
workflow_dispatch:
11+
inputs:
12+
branch:
13+
description: 'Branch name'
14+
required: true
1115

1216
jobs:
1317
add-tag:
@@ -17,20 +21,40 @@ jobs:
1721
cancel-in-progress: true
1822
steps:
1923
- name: Checkout
24+
if: github.event_name != 'workflow_dispatch'
2025
uses: actions/checkout@v4
2126
with:
2227
fetch-depth: 0
2328
ref: ${{ github.event.pull_request.head.ref }}
2429
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+
2539
- 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
2848
run: |
2949
git config user.name 'github-actions'
3050
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
3151
git tag --delete latest
3252
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
3458
git push origin refs/tags/latest
3559
3660
call-test-action:

0 commit comments

Comments
 (0)