|
1 |
| -# This is a basic workflow to help you get started with Actions |
| 1 | +name: Builds, tests & co |
2 | 2 |
|
3 |
| -name: Run tests |
4 |
| - |
5 |
| -# Controls when the action will run. |
6 | 3 | on:
|
7 |
| - # Triggers the workflow on push or pull request events but only for the master branch |
8 |
| - pull_request: |
9 |
| - branches: [ master, next ] |
10 |
| - |
11 |
| - # Allows you to run this workflow manually from the Actions tab |
12 |
| - workflow_dispatch: |
| 4 | + - push |
| 5 | + - pull_request |
13 | 6 |
|
14 |
| -# A workflow run is made up of one or more jobs that can run sequentially or in parallel |
15 | 7 | jobs:
|
16 |
| - # This workflow contains a single job called "build" |
17 |
| - build: |
18 |
| - # The type of runner that the job will run on |
19 |
| - runs-on: ubuntu-latest |
| 8 | + build-and-test: |
20 | 9 | strategy:
|
| 10 | + fail-fast: false |
21 | 11 | matrix:
|
22 |
| - node-version: [11.x, 13.x, 15.x] |
| 12 | + os: |
| 13 | + - macos-latest |
| 14 | + - ubuntu-latest |
| 15 | + - windows-latest |
| 16 | + node-version: |
| 17 | + - 14.x |
| 18 | + - 16.x |
| 19 | + - 18.x |
23 | 20 |
|
24 |
| - name: Node.js (test-all) ${{ matrix.node-version }} |
| 21 | + runs-on: ${{ matrix.os }} |
25 | 22 |
|
26 |
| - # Steps represent a sequence of tasks that will be executed as part of the job |
27 | 23 | steps:
|
28 |
| - # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it |
29 |
| - - uses: actions/checkout@v2 |
| 24 | + - name: Checkout tree |
| 25 | + uses: actions/checkout@v3 |
| 26 | + |
| 27 | + - name: Use Node.js ${{ matrix.node-version }} |
| 28 | + uses: actions/setup-node@v3 |
| 29 | + with: |
| 30 | + node-version: ${{ matrix.node-version }} |
| 31 | + |
| 32 | + - name: Install npm packages |
| 33 | + run: npm ci --ignore-scripts |
| 34 | + |
| 35 | + - name: Run the tests |
| 36 | + run: npm run test-all |
| 37 | + |
| 38 | + dependabot-auto-approve: |
| 39 | + name: Dependabot auto-approve |
| 40 | + |
| 41 | + permissions: |
| 42 | + pull-requests: write |
| 43 | + |
| 44 | + needs: |
| 45 | + - build-and-test |
| 46 | + |
| 47 | + if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }} |
| 48 | + |
| 49 | + runs-on: ubuntu-latest |
30 | 50 |
|
31 |
| - # Runs a single command using the runners shell |
32 |
| - - name: install deps |
33 |
| - run: npm i |
| 51 | + steps: |
| 52 | + - name: Fetch Dependabot metadata |
| 53 | + id: metadata |
| 54 | + uses: dependabot/fetch-metadata@v1 |
| 55 | + |
| 56 | + - name: Get the PR review decision |
| 57 | + id: gh-pr-review |
| 58 | + run: echo "decision=$(gh pr view --json reviewDecision --jq '. | .reviewDecision' "$PR_URL")" >>"$GITHUB_OUTPUT" |
| 59 | + env: |
| 60 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 61 | + GITHUB_TOKEN: ${{ github.token }} |
| 62 | + |
| 63 | + - name: Approve a PR |
| 64 | + if: ${{ steps.gh-pr-review.outputs.decision != 'APPROVED' && steps.metadata.outputs.update-type == 'version-update:semver-patch' }} |
| 65 | + run: gh pr review --approve "$PR_URL" |
| 66 | + env: |
| 67 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 68 | + GITHUB_TOKEN: ${{ github.token }} |
| 69 | + |
| 70 | + dependabot-auto-merge: |
| 71 | + name: Dependabot auto-merge |
| 72 | + |
| 73 | + permissions: |
| 74 | + contents: write |
| 75 | + pull-requests: write |
| 76 | + |
| 77 | + if: ${{ github.event_name == 'pull_request' && github.actor == 'dependabot[bot]' }} |
| 78 | + |
| 79 | + needs: |
| 80 | + - build-and-test |
| 81 | + - dependabot-auto-approve |
| 82 | + |
| 83 | + runs-on: ubuntu-latest |
| 84 | + |
| 85 | + steps: |
| 86 | + - name: Fetch Dependabot metadata |
| 87 | + id: metadata |
| 88 | + uses: dependabot/fetch-metadata@v1 |
34 | 89 |
|
35 |
| - # Runs a set of commands using the runners shell |
36 |
| - - name: test |
37 |
| - run: npm run test-all-extended |
| 90 | + - name: Merge Dependabot PR |
| 91 | + if: ${{ steps.metadata.outputs.update-type == 'version-update:semver-patch' }} |
| 92 | + run: gh pr merge --auto --merge "$PR_URL" |
| 93 | + env: |
| 94 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 95 | + GITHUB_TOKEN: ${{ github.token }} |
0 commit comments