Skip to content

Commit b1ddf91

Browse files
authored
support GH_HOST (#98)
* fix * fix warn
1 parent cb3bcaf commit b1ddf91

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

.github/workflows/main.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ jobs:
115115
jq . < "${GITHUB_EVENT_PATH}" | tee github_event.json
116116
- name: Create act event.json
117117
run: |
118-
gh act "${ACT_EVENT_NAME}" -e gh_act_event_raw.json -j noop
118+
gh act "${ACT_EVENT_NAME}" -e gh_act_event_raw.json -j noop -W .github/workflows/main.yml
119119
jq . < gh_act_event_raw.json | tee gh_act_event.json
120120
- name: Diff
121121
run: |

gh-act

+9-4
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ set -euo pipefail
44
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" &>/dev/null && pwd -P)
55

66
GH_ACT_VERSION=0.5
7+
declare -a ACT_OPTIONS
78
TEMPFILE_DIR=
89

910
msg() {
@@ -63,7 +64,8 @@ parse_params() {
6364
# default values of variables set from params
6465
EVENT_NAME=
6566
EVENT_PATH=
66-
GITHUB_HOSTNAME='github.com'
67+
GITHUB_INSTANCE=
68+
GITHUB_HOSTNAME="${GH_HOST:-github.com}"
6769
AUTO_GITHUB_TOKEN=${GHACT_AUTO_GITHUB_TOKEN:-true}
6870
ACT_JOB=
6971
ACT_DRYRUN=false
@@ -118,7 +120,8 @@ parse_params() {
118120
EVENT_PATH="${2-}"
119121
shift ;;
120122
--github-instance )
121-
GITHUB_HOSTNAME="${2-}"
123+
GITHUB_INSTANCE="${2-}"
124+
GITHUB_HOSTNAME="${GITHUB_INSTANCE}"
122125
shift ;;
123126
-j| --job )
124127
ACT_JOB="${2-}"
@@ -169,6 +172,9 @@ parse_params() {
169172
GITHUB_API="api.github.com"
170173
else
171174
GITHUB_API="${GITHUB_HOSTNAME}/api/v3"
175+
if [ -z "${GITHUB_INSTANCE}" ]; then
176+
ACT_OPTIONS+=(--github-instance "${GITHUB_HOSTNAME}")
177+
fi
172178
fi
173179
if [ -z "${EVENT_NAME}" ]; then
174180
EVENT_NAME="push"
@@ -1302,7 +1308,6 @@ function main() {
13021308
DATE_NOW=$(date +"%Y-%m-%dT%H:%M:%S%z")
13031309
DATE_UTC_NOW=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
13041310

1305-
declare -a ACT_OPTIONS
13061311
if "${AUTO_GITHUB_TOKEN}"; then
13071312
if [ -n "${GITHUB_TOKEN:-}" ]; then
13081313
ACT_OPTIONS+=(-s "GITHUB_TOKEN=${GITHUB_TOKEN}")
@@ -1348,7 +1353,7 @@ function main() {
13481353
ACT_OPTIONS+=(--artifact-server-path "${TEMP_ARTIFACT_DIR}")
13491354
fi
13501355

1351-
# act "$@" "${ACT_OPTIONS[@]}" && act_post_action
1356+
act "$@" "${ACT_OPTIONS[@]}" && act_post_action
13521357
}
13531358

13541359
case "${EVENT_NAME:-}" in

0 commit comments

Comments
 (0)