Skip to content

Commit fd4983c

Browse files
authored
support action specific envrionment variable (GHACT_ACTION) (#74)
1 parent ece0527 commit fd4983c

16 files changed

Lines changed: 48 additions & 46 deletions

Makefile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ clean:
1717
rm -rf gh-act.* *.json
1818

1919
repository_dispatch:
20-
curl -X POST -H "Accept: application/vnd.github+json" -H "Authorization: token ${GH_TOKEN}" \
21-
https://api.github.com/repos/srz-zumix/gh-act/dispatches \
22-
-d '{"event_type":"on-demand-test","client_payload":{"unit":false,"integration":true}}'
20+
jq -n '{"event_type":"on-demand-test","client_payload":{"unit":false,"integration":true}}' | \
21+
gh api -H "Accept: application/vnd.github+json" \
22+
/repos/srz-zumix/gh-act/dispatches \
23+
--input -

README.md

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -29,38 +29,39 @@ Please check [test workflow][](Diff step) for the difference between the generat
2929

3030
Supported Events
3131

32-
| Event | Configurable environment variables |
33-
|:-----------------------|:-----------------------------------|
34-
| branch_protection_rule | |
35-
| check_run | GHACT_BRANCH |
36-
| check_suite | GHACT_BRANCH |
37-
| create | GHACT_BRANCH |
38-
| delete | GHACT_BRANCH |
39-
| discussion | GHACT_DISCUSSION_NUMBER |
40-
| discussion_comment | GHACT_DISCUSSION_NUMBER |
41-
| gollum | |
42-
| issue_comment | GHACT_ISSUE_NUMBER |
43-
| issues | GHACT_ISSUE_NUMBER |
44-
| label | |
45-
| milestone | GHACT_MILESTONE_NUMBER |
46-
| page_build | |
47-
| public | |
48-
| pull_request | GHACT_BRANCH,GHACT_PULL_REQUEST_SPEC,GHACT_PULL_REQUEST_NUMBER |
49-
| pull_request_review | GHACT_BRANCH,GHACT_PULL_REQUEST_SPEC,GHACT_PULL_REQUEST_NUMBER |
50-
| pull_request_target | GHACT_BRANCH,GHACT_PULL_REQUEST_SPEC,GHACT_PULL_REQUEST_NUMBER |
51-
| push | GHACT_BRANCH |
52-
| registry_package | GHACT_BRANCH,GHACT_PACKAGE_TYPE,GHACT_PACKAGE_TYPE |
53-
| release | GHACT_RELEASE_NAME |
54-
| repository_dispatch | GHACT_CLIENT_PAYLOAD |
55-
| schedule | GHACT_SCHEDULE_CRON |
56-
| status | GHACT_BRANCH |
57-
| watch | |
58-
| workflow_dispatch | GHACT_INPUTS |
32+
| Event | Configurable environment variables (prefix: GHACT_) | default action |
33+
|:-----------------------|:-----------------------------------|-----------------|
34+
| branch_protection_rule | ACTION | created |
35+
| check_run | ACTION,BRANCH | completed |
36+
| check_suite | ACTION,BRANCH | completed |
37+
| create | BRANCH | |
38+
| delete | BRANCH | |
39+
| discussion | ACTION,DISCUSSION_NUMBER | created |
40+
| discussion_comment | ACTION,DISCUSSION_NUMBER | created |
41+
| gollum | ACTION | created |
42+
| issue_comment | ACTION,ISSUE_NUMBER | created |
43+
| issues | ACTION,ISSUE_NUMBER | opened |
44+
| label | ACTION | created |
45+
| milestone | ACTION,MILESTONE_NUMBER | created |
46+
| page_build | | |
47+
| public | | |
48+
| pull_request | ACTION,BRANCH,PULL_REQUEST_SPEC,PULL_REQUEST_NUMBER | synchronize |
49+
| pull_request_review | ACTION,BRANCH,PULL_REQUEST_SPEC,PULL_REQUEST_NUMBER | submiited |
50+
| pull_request_target | ACTION,BRANCH,PULL_REQUEST_SPEC,PULL_REQUEST_NUMBER | synchronize |
51+
| push | BRANCH | |
52+
| registry_package | ACTION,BRANCH,PACKAGE_TYPE,PACKAGE_TYPE | published |
53+
| release | ACTION,RELEASE_NAME | released |
54+
| repository_dispatch | ACTION,CLIENT_PAYLOAD | (empty) |
55+
| schedule | SCHEDULE_CRON | |
56+
| status | BRANCH | |
57+
| watch | ACTION | started |
58+
| workflow_dispatch | INPUTS | |
5959

6060
### Environment Variables
6161

6262
| name | description | default |
6363
|:---------------------------|:---------------------------------------------------------------------------------------|:-----------------------|
64+
| GHACT_ACTION | specify action name | (per [events](#Events))|
6465
| GHACT_AUTO_GITHUB_TOKEN | flag to automatically set the GITHUB_TOKEN secret | true |
6566
| GHACT_BRANCH | specify branch name | current branch |
6667
| GHACT_CLIENT_PAYLOAD | repository_dispatch client_payload json string | null |

templates/branch_protection_rule.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"action": "created",
2+
"action": "${GHACT_ACTION;-created}",
33
"repository": ${HEAD_REPO_JSON},
44
"rule": {
55
"admin_enforced": ${BRANCH_PROTECTION_RULE_IS_ADMIN_ENFORCED},

templates/check_run.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"action": "completed",
2+
"action": "${GHACT_ACTION:-completed}",
33
"check_run": {
44
"app": ${CHECK_APP_JSON},
55
"check_suite": {

templates/check_suite.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"action": "completed",
2+
"action": "${GHACT_ACTION:-completed}",
33
"check_suite": {
44
"after": "${HEAD}",
55
"app": ${CHECK_APP_JSON},

templates/discussion.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"action": "created",
2+
"action": "${GHACT_ACTION:-created}",
33
"discussion": ${DISCUSSION_JSON},
44
"repository": ${HEAD_REPO_JSON},
55
"sender": ${HEAD_USER_JSON}
6-
}
6+
}

templates/discussion_comment.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"action": "created",
2+
"action": "${GHACT_ACTION:-created}",
33
"comment": {
44
"author_association": "${DISCUSSION_COMMENT_AUTHOR_ASSOCIATION}",
55
"body": "${DISCUSSION_COMMENT_BODY}",

templates/gollum.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"pages": [
33
{
4-
"action": "created",
4+
"action": "${GHACT_ACTION:-created}",
55
"html_url": "https://${GITHUB_HOSTNAME}/${OWNER}/${REPO}/wiki/Home",
66
"page_name": "Home",
77
"sha": "$(git ls-remote https://${GITHUB_HOSTNAME}/${OWNER}/${REPO}.wiki.git HEAD 2>/dev/null | grep -o -E '^[0-9A-Za-z]*' || echo ${HEAD})",
@@ -11,4 +11,4 @@
1111
],
1212
"repository": ${HEAD_REPO_JSON},
1313
"sender": ${HEAD_USER_JSON}
14-
}
14+
}

templates/issue_comment.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"action": "created",
2+
"action": "${GHACT_ACTION:-created}",
33
"comment": {
44
"author_association": "${ISSUE_COMMENT_AUTHOR_ASSOCIATION}",
55
"body": "${ISSUE_COMMENT_BODY}",

templates/issues.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"action": "opened",
2+
"action": "${GHACT_ACTION:-opened}",
33
"issue": ${ISSUE_JSON},
44
"repository": ${HEAD_REPO_JSON},
55
"sender": ${HEAD_USER_JSON}

0 commit comments

Comments
 (0)