Skip to content

Commit

Permalink
fixup! fixup! tools: use gh CLI for CI and commit queue jobs
Browse files Browse the repository at this point in the history
  • Loading branch information
targos committed Nov 6, 2021
1 parent f4f8836 commit e75acb0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
14 changes: 7 additions & 7 deletions tools/actions/commit-queue.sh
Expand Up @@ -4,13 +4,13 @@ set -xe

OWNER=$1
REPOSITORY=$2
GITHUB_TOKEN=$3
shift 3
shift 2

UPSTREAM=origin
DEFAULT_BRANCH=master

API_URL=https://api.github.com
COMMIT_QUEUE_LABEL="commit-queue"
COMMIT_QUEUE_FAILED_LABEL="commit-queue-failed"

mergeUrl() {
echo "repos/${OWNER}/${REPOSITORY}/pulls/${1}/merge"
Expand All @@ -19,14 +19,14 @@ mergeUrl() {
commit_queue_failed() {
pr=$1

gh pr edit $pr --add-label "${COMMIT_QUEUE_FAILED_LABEL}"
gh pr edit "$pr" --add-label "${COMMIT_QUEUE_FAILED_LABEL}"

# shellcheck disable=SC2154
cqurl="${GITHUB_SERVER_URL}/${OWNER}/${REPOSITORY}/actions/runs/${GITHUB_RUN_ID}"
body="<details><summary>Commit Queue failed</summary><pre>$(cat output)</pre><a href='$cqurl'>$cqurl</a></details>"
echo "$body"

gh pr comment $pr --body "$body"
gh pr comment "$pr" --body "$body"

rm output
}
Expand All @@ -36,7 +36,7 @@ git config --local user.email "github-bot@iojs.org"
git config --local user.name "Node.js GitHub Bot"

for pr in "$@"; do
gh pr view $pr --json labels --jq ".labels" > labels.json
gh pr view "$pr" --json labels --jq ".labels" > labels.json
# Skip PR if CI was requested
if jq -e 'map(.name) | index("request-ci")' < labels.json; then
echo "pr ${pr} skipped, waiting for CI to start"
Expand All @@ -50,7 +50,7 @@ for pr in "$@"; do
fi

# Delete the commit queue label
gh pr edit $pr --remove-label "$COMMIT_QUEUE_LABEL"
gh pr edit "$pr" --remove-label "$COMMIT_QUEUE_LABEL"

if jq -e 'map(.name) | index("commit-queue-squash")' < labels.json; then
MULTIPLE_COMMIT_POLICY="--fixupAll"
Expand Down
10 changes: 5 additions & 5 deletions tools/actions/start-ci.sh
Expand Up @@ -2,11 +2,11 @@

set -xe

REQUEST_CI_LABEL=request-ci
REQUEST_CI_FAILED_LABEL=request-ci-failed
REQUEST_CI_LABEL="request-ci"
REQUEST_CI_FAILED_LABEL="request-ci-failed"

for pr in "$@"; do
gh pr edit $pr --remove-label "$REQUEST_CI_LABEL"
gh pr edit "$pr" --remove-label "$REQUEST_CI_LABEL"

ci_started=yes
rm -f output;
Expand All @@ -15,11 +15,11 @@ for pr in "$@"; do

if [ "$ci_started" = "no" ]; then
# Do we need to reset?
gh pr edit $pr --add-label "$REQUEST_CI_FAILED_LABEL"
gh pr edit "$pr" --add-label "$REQUEST_CI_FAILED_LABEL"

jq -n --arg content "<details><summary>Couldn't start CI</summary><pre>$(cat output)</pre></details>" > output.json

gh pr comment $pr --body-file output.json
gh pr comment "$pr" --body-file output.json

rm output.json;
fi
Expand Down

0 comments on commit e75acb0

Please sign in to comment.