|
| 1 | +name: Check Yarn |
| 2 | + |
| 3 | +# See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows |
| 4 | +on: |
| 5 | + create: |
| 6 | + push: |
| 7 | + paths: |
| 8 | + - ".github/workflows/check-yarn.ya?ml" |
| 9 | + - "**/.yarnrc" |
| 10 | + - "**/package.json" |
| 11 | + - "**/package-lock.json" |
| 12 | + - "**/yarn.lock" |
| 13 | + pull_request: |
| 14 | + paths: |
| 15 | + - ".github/workflows/check-yarn.ya?ml" |
| 16 | + - "**/.yarnrc" |
| 17 | + - "**/package.json" |
| 18 | + - "**/package-lock.json" |
| 19 | + - "**/yarn.lock" |
| 20 | + schedule: |
| 21 | + # Run every Tuesday at 8 AM UTC to catch breakage resulting from changes to the JSON schema. |
| 22 | + - cron: "0 8 * * TUE" |
| 23 | + workflow_dispatch: |
| 24 | + repository_dispatch: |
| 25 | + |
| 26 | +jobs: |
| 27 | + run-determination: |
| 28 | + runs-on: ubuntu-latest |
| 29 | + permissions: {} |
| 30 | + outputs: |
| 31 | + result: ${{ steps.determination.outputs.result }} |
| 32 | + steps: |
| 33 | + - name: Determine if the rest of the workflow should run |
| 34 | + id: determination |
| 35 | + run: | |
| 36 | + RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x" |
| 37 | + # The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead. |
| 38 | + if [[ |
| 39 | + "${{ github.event_name }}" != "create" || |
| 40 | + "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX |
| 41 | + ]]; then |
| 42 | + # Run the other jobs. |
| 43 | + RESULT="true" |
| 44 | + else |
| 45 | + # There is no need to run the other jobs. |
| 46 | + RESULT="false" |
| 47 | + fi |
| 48 | +
|
| 49 | + echo "result=$RESULT" >> $GITHUB_OUTPUT |
| 50 | +
|
| 51 | + check-sync: |
| 52 | + name: check-sync (${{ matrix.project.path }}) |
| 53 | + needs: run-determination |
| 54 | + if: needs.run-determination.outputs.result == 'true' |
| 55 | + runs-on: ubuntu-latest |
| 56 | + permissions: |
| 57 | + contents: read |
| 58 | + |
| 59 | + strategy: |
| 60 | + fail-fast: false |
| 61 | + matrix: |
| 62 | + project: |
| 63 | + - path: . |
| 64 | + |
| 65 | + steps: |
| 66 | + - name: Checkout repository |
| 67 | + uses: actions/checkout@v4 |
| 68 | + |
| 69 | + - name: Setup Node.js |
| 70 | + uses: actions/setup-node@v4 |
| 71 | + with: |
| 72 | + cache: yarn |
| 73 | + node-version: ${{ env.NODE_VERSION }} |
| 74 | + |
| 75 | + - name: Install npm package dependencies |
| 76 | + env: |
| 77 | + # Avoid failure of @vscode/ripgrep installation due to GitHub API rate limiting: |
| 78 | + # https://github.com/microsoft/vscode-ripgrep#github-api-limit-note |
| 79 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 80 | + run: | |
| 81 | + yarn \ |
| 82 | + install \ |
| 83 | + --ignore-scripts |
| 84 | +
|
| 85 | + - name: Check yarn.lock |
| 86 | + run: | |
| 87 | + git \ |
| 88 | + diff \ |
| 89 | + --color \ |
| 90 | + --exit-code \ |
| 91 | + "${{ matrix.project.path }}/yarn.lock" |
0 commit comments