-
-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (133 loc) · 3.59 KB
/
main.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
name: gh act tests
on:
branch_protection_rule:
create:
check_run:
check_suite:
# delete:
discussion:
discussion_comment:
gollum:
issue_comment:
issues:
label:
merge_group:
milestone:
page_build:
public:
pull_request:
types:
- assigned
- unassigned
- labeled
- unlabeled
- opened
- edited
- closed
- reopened
- synchronize
- converted_to_draft
- ready_for_review
- locked
- unlocked
- review_requested
- review_request_removed
- auto_merge_enabled
- auto_merge_disabled
pull_request_review:
pull_request_review_comment:
pull_request_target:
types:
- assigned
- unassigned
- labeled
- unlabeled
- opened
- edited
- closed
- reopened
- synchronize
- converted_to_draft
- ready_for_review
- locked
- unlocked
- review_requested
- review_request_removed
- auto_merge_enabled
- auto_merge_disabled
push:
registry_package:
release:
repository_dispatch:
types: [on-demand-test]
schedule:
- cron: '0 0 * * 0'
status:
watch:
workflow_dispatch:
inputs:
event:
description: 'event name'
default: 'workflow_dispatch'
required: true
workflow_run:
workflows: [Lint]
types:
- requested
- completed
# https://github.com/srz-zumix/gh-act/issues/57
permissions: write-all
jobs:
test:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
ACT_EVENT_NAME: ${{ inputs.event || github.event_name }}
steps:
- uses: actions/checkout@v4
with:
ref: ${{ (contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref) || github.ref }}
fetch-depth: 0
- name: Install gh
run: |
curl -fsSL https://cli.github.com/packages/githubcli-archive-keyring.gpg | sudo dd of=/usr/share/keyrings/githubcli-archive-keyring.gpg
chmod go+r /usr/share/keyrings/githubcli-archive-keyring.gpg
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/githubcli-archive-keyring.gpg] https://cli.github.com/packages stable main" | sudo tee /etc/apt/sources.list.d/github-cli.list > /dev/null
apt update
apt install gh
if: ${{ env.ACT }}
- name: Install act
run: |
curl https://raw.githubusercontent.com/nektos/act/master/install.sh | sudo bash
echo "./bin" >> "${GITHUB_PATH}"
{
echo "-P ubuntu-latest=ghcr.io/catthehacker/ubuntu:act-latest"
echo "-P ubuntu-20.04=ghcr.io/catthehacker/ubuntu:act-20.04"
echo "-P ubuntu-18.04=ghcr.io/catthehacker/ubuntu:act-18.04"
} > .actrc
- name: Install gh-act
run: |
make install
- name: Dump github.event
run: |
jq . < "${GITHUB_EVENT_PATH}" | tee github_event.json
- name: Create act event.json
run: |
gh act "${ACT_EVENT_NAME}" -e gh_act_event_raw.json -j noop -W .github/workflows/main.yml
jq . < gh_act_event_raw.json | tee gh_act_event.json
- name: Diff
run: |
diff github_event.json gh_act_event.json || :
if: github.event_name == env.ACT_EVENT_NAME
- name: Docker ps
run: |
docker ps
noop:
runs-on: ubuntu-latest
# jobs.*.if では env 参照できない
# actor で判断している
if: github.actor == 'nektos/act'
steps:
- uses: actions/checkout@v4
with:
ref: ${{ (contains(github.event_name, 'pull_request') && github.event.pull_request.head.ref) || github.ref }}