-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
102 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
name: Auto Start CI | ||
|
||
on: | ||
schedule: | ||
# Runs every five minutes (fastest the scheduler can run). Five minutes is | ||
# optimistic, it can take longer to run. | ||
# To understand why `schedule` is used instead of other events, refer to | ||
# ./doc/contributing/commit-queue.md | ||
- cron: '*/5 * * * *' | ||
|
||
concurrency: ${{ github.workflow }} | ||
|
||
env: | ||
NODE_VERSION: lts/* | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
get-prs-for-ci: | ||
permissions: | ||
pull-requests: read | ||
if: github.repository == 'nodejs/node' | ||
runs-on: ubuntu-latest | ||
outputs: | ||
numbers: ${{ steps.get_prs_for_ci.outputs.numbers }} | ||
steps: | ||
- name: Get Pull Requests | ||
id: get_prs_for_ci | ||
run: > | ||
gh pr list \ | ||
--repo ${{ github.repository }} \ | ||
--label 'resume-ci' \ | ||
--json 'number' \ | ||
-t '::set-output name=numbers::{{ range . }}{{ .number }} {{ end }}' \ | ||
--limit 100 | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
start-ci: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
needs: get-prs-for-ci | ||
if: needs.get-prs-for-ci.outputs.numbers != '' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
persist-credentials: false | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ env.NODE_VERSION }} | ||
|
||
- name: Install node-core-utils | ||
run: npm install -g node-core-utils | ||
|
||
- name: Setup node-core-utils | ||
run: | | ||
ncu-config set username ${{ secrets.JENKINS_USER }} | ||
ncu-config set token none | ||
ncu-config set jenkins_token ${{ secrets.JENKINS_TOKEN }} | ||
ncu-config set owner "${{ github.repository_owner }}" | ||
ncu-config set repo "$(echo ${{ github.repository }} | cut -d/ -f2)" | ||
- name: Resume the CI Runs | ||
run: ./tools/actions/resume-ci.sh ${{ needs.get-prs-for-ci.outputs.numbers }} | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
set -xe | ||
|
||
RESUME_CI_LABEL="resume-ci" | ||
RESUME_CI_FAILED_LABEL="resume-ci-failed" | ||
|
||
for pr in "$@"; do | ||
gh pr edit "$pr" --remove-label "$RESUME_CI_LABEL" | ||
|
||
ci_started=yes | ||
rm -f output; | ||
ncu-ci resume "$pr" >output 2>&1 || ci_started=no | ||
cat output | ||
|
||
if [ "$ci_started" = "no" ]; then | ||
# Do we need to reset? | ||
gh pr edit "$pr" --add-label "$RESUME_CI_FAILED_LABEL" | ||
|
||
jq -n --arg content "<details><summary>Couldn't resume CI</summary><pre>$(cat output || true)</pre></details>" > output.json | ||
|
||
gh pr comment "$pr" --body-file output.json | ||
|
||
rm output.json; | ||
fi | ||
done; |