Skip to content

Commit

Permalink
Merge branch 'main' into feature/help_option
Browse files Browse the repository at this point in the history
  • Loading branch information
srz-zumix authored Nov 29, 2023
2 parents 118adcb + d3c2b0f commit e6e371d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deployment-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ on:
workflow_dispatch:

jobs:
test:
deployment-test:
runs-on: ubuntu-latest
environment: gh-act-env
steps:
Expand Down
34 changes: 24 additions & 10 deletions gh-act
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ set -euo pipefail
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]:-$0}")" &>/dev/null && pwd -P)

GH_ACT_VERSION=0.5
TEMPFILE_DIR=

msg() {
echo >&2 -e "${1-}"
Expand Down Expand Up @@ -202,7 +203,7 @@ function is_valid_user {
return $?
}

function user_json {
function user_json_ {
# shellcheck disable=SC2016,SC2086
USER_JSON_TEMPLATE='{
"avatar_url": "{{.avatar_url}}",
Expand Down Expand Up @@ -233,6 +234,14 @@ function user_json {
fi
}

function user_json {
if [ -f "${TEMPFILE_DIR}/users/$1.json" ]; then
cat "${TEMPFILE_DIR}/users/$1.json"
else
user_json_ "$1" | tee "${TEMPFILE_DIR}/users/$1.json"
fi
}

function issue_json {
ISSUE_NUMBER=$1
parts_json issue
Expand Down Expand Up @@ -429,12 +438,16 @@ function pull_request_event_envs() {
fi

pr_envs "${PULL_REQUEST_SPEC}"

# shellcheck disable=SC2086
HEAD=$(gh pr view ${PULL_REQUEST_SPEC} --json commits --jq .commits[].oid | tail -1)
# shellcheck disable=SC2086
HEAD_USER=$(gh pr view ${PULL_REQUEST_SPEC} --json commits --jq .commits[].authors[].login | tail -1)
# shellcheck disable=SC2086
BEFORE=$(gh pr view ${PULL_REQUEST_SPEC} --json commits --jq .commits[].oid | tail -2 | head -1)
BEFORE=$(gh pr view "${PULL_REQUEST_SPEC}" --json commits --jq .commits[].oid | tail -2 | head -1)
# shellcheck disable=SC2046
read -r HEAD HEAD_USER <<< $(gh pr view "${PULL_REQUEST_SPEC}" --json commits \
--template '{{- $last := 0}}

Check warning on line 446 in gh-act

View workflow job for this annotation

GitHub Actions / shellcheck

[shellcheck] reported by reviewdog 🐶 Expressions don't expand in single quotes, use double quotes for that. [SC2016](https://github.com/koalaman/shellcheck/wiki/SC2016) Raw Output: ./gh-act:446:20:info:Expressions don't expand in single quotes, use double quotes for that. [SC2016](https://github.com/koalaman/shellcheck/wiki/SC2016)
{{- range $index, $element := .commits}}{{$last = $index}}{{end}}
{{- $commit := index .commits $last}}
{{- $author := index $commit.authors 0}}
{{- $commit.oid }} {{ $author.login -}}')

# base
repo_envs "${OWNER}/${REPO}" "BASE"
Expand Down Expand Up @@ -1167,8 +1180,9 @@ function create_event_json() {
if [ -f "${SCRIPT_DIR}/templates/${EVENT_NAME}.json" ]; then

# common
OWNER=$(gh repo view --json owner --jq .owner.login)
REPO=$(gh repo view --json name --jq .name)
# shellcheck disable=SC2046
read -r OWNER REPO \
<<< $(gh repo view --json owner,name --template '{{ .owner.login }} {{ .name }}')

evnet_envs

Expand Down Expand Up @@ -1270,10 +1284,10 @@ function act_post_action() {
true
}

TEMPFILE_DIR=
function tempdir() {
if [ -z "${TEMPFILE_DIR}" ] || [ ! -d "${TEMPFILE_DIR}" ]; then
TEMPFILE_DIR=$(mktemp -d gh-act.XXXXXX)
mkdir "${TEMPFILE_DIR}/users"
trap 'rm -rf "${TEMPFILE_DIR}"' EXIT
fi
}
Expand Down Expand Up @@ -1334,7 +1348,7 @@ function main() {
ACT_OPTIONS+=(--artifact-server-path "${TEMP_ARTIFACT_DIR}")
fi

act "$@" "${ACT_OPTIONS[@]}" && act_post_action
# act "$@" "${ACT_OPTIONS[@]}" && act_post_action
}

case "${EVENT_NAME:-}" in
Expand Down
5 changes: 2 additions & 3 deletions templates/parts/repo.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,6 @@
"squash_merge_commit_message": "COMMIT_MESSAGES",
"squash_merge_commit_title": "COMMIT_OR_PR_TITLE",
"ssh_url": "${REPO_SSH_URL}",
"stargazers": ${REPO_STARGAZER_COUNT},
"stargazers_count": ${REPO_STARGAZER_COUNT},
"stargazers_url": "https://${GITHUB_API}/repos/${OWNER}/${REPO}/stargazers",
"statuses_url": "https://${GITHUB_API}/repos/${OWNER}/${REPO}/statuses/{sha}",
Expand All @@ -90,7 +89,7 @@
"url": "https://${GITHUB_API}/repos/${OWNER}/${REPO}",
"use_squash_pr_title_as_default": false,
"visibility": "${VISIBILITY}",
"watchers": ${REPO_WATCHERS_TOTAL_COUNT},
"watchers_count": ${REPO_WATCHERS_TOTAL_COUNT},
"watchers": ${REPO_STARGAZER_COUNT},
"watchers_count": ${REPO_STARGAZER_COUNT},
"web_commit_signoff_required": false
}

0 comments on commit e6e371d

Please sign in to comment.