|
| 1 | +--- |
| 2 | +name: Auto Start CI |
| 3 | + |
| 4 | +on: |
| 5 | + push: |
| 6 | + schedule: |
| 7 | + # `schedule` event is used instead of `pull_request` because when a |
| 8 | + # `pull_requesst` event is triggered on a PR from a fork, GITHUB_TOKEN will |
| 9 | + # be read-only, and the Action won't have access to any other repository |
| 10 | + # secrets, which it needs to access Jenkins API. Runs every five minutes |
| 11 | + # (fastest the scheduler can run). Five minutes is optimistic, it can take |
| 12 | + # longer to run. |
| 13 | + - cron: "*/5 * * * *" |
| 14 | + |
| 15 | +jobs: |
| 16 | + commitQueue: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + steps: |
| 19 | + - uses: actions/checkout@master |
| 20 | + |
| 21 | + # Install dependencies |
| 22 | + - name: Install jq |
| 23 | + run: sudo apt-get install jq -y |
| 24 | + - name: Install Node.js |
| 25 | + uses: actions/setup-node@v2-beta |
| 26 | + with: |
| 27 | + node-version: '12' |
| 28 | + - name: Install node-core-utils |
| 29 | + run: npm install -g node-core-utils |
| 30 | + |
| 31 | + - name: Set variables |
| 32 | + run: | |
| 33 | + echo "::set-env name=REPOSITORY::$(echo ${{ github.repository }} | cut -d/ -f2)" |
| 34 | + echo "::set-env name=OWNER::${{ github.repository_owner }}" |
| 35 | +
|
| 36 | + # Get Pull Requests |
| 37 | + - name: Get Pull Requests |
| 38 | + |
| 39 | + id: get_prs_for_ci |
| 40 | + with: |
| 41 | + query: | |
| 42 | + query prs($owner:String!, $repo:String!) { |
| 43 | + repository(owner:$owner, name:$repo) { |
| 44 | + pullRequests(labels: ["request-ci"], states: OPEN, last: 100) { |
| 45 | + nodes { |
| 46 | + number |
| 47 | + } |
| 48 | + } |
| 49 | + } |
| 50 | + } |
| 51 | + owner: ${{ env.OWNER }} |
| 52 | + repo: ${{ env.REPOSITORY }} |
| 53 | + env: |
| 54 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 55 | + |
| 56 | + - name: Setup node-core-utils |
| 57 | + run: | |
| 58 | + ncu-config set username ${{ secrets.JENKINS_USER }} |
| 59 | + ncu-config set token none |
| 60 | + ncu-config set jenkins_token ${{ secrets.JENKINS_TOKEN }} |
| 61 | + ncu-config set owner ${{ env.OWNER }} |
| 62 | + ncu-config set repo ${{ env.REPOSITORY }} |
| 63 | +
|
| 64 | + - name: Start CI |
| 65 | + run: ./tools/start-ci.sh ${{ secrets.GITHUB_TOKEN }} ${{ env.OWNER }} ${{ env.REPOSITORY }} $(echo '${{ steps.get_prs_for_ci.outputs.data }}' | jq '.repository.pullRequests.nodes | map(.number) | .[]') |
0 commit comments