|
| 1 | +name: Main |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [main] |
| 6 | + pull_request: |
| 7 | + merge_group: |
| 8 | + |
| 9 | +concurrency: |
| 10 | + group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.sha || github.ref }} |
| 11 | + cancel-in-progress: ${{ !contains(github.ref, 'refs/heads/main') }} |
| 12 | + |
| 13 | +permissions: |
| 14 | + contents: read |
| 15 | + |
| 16 | +jobs: |
| 17 | + check-workflows: |
| 18 | + name: Check workflows |
| 19 | + runs-on: ubuntu-latest |
| 20 | + steps: |
| 21 | + - uses: actions/checkout@v5 |
| 22 | + - name: Download actionlint |
| 23 | + id: download-actionlint |
| 24 | + run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/914e7df21a07ef503a81201c76d2b11c789d3fca/scripts/download-actionlint.bash) 1.7.12 |
| 25 | + shell: bash |
| 26 | + - name: Check workflow files |
| 27 | + run: ${{ steps.download-actionlint.outputs.executable }} -color |
| 28 | + shell: bash |
| 29 | + |
| 30 | + analyse-code: |
| 31 | + name: Analyse code |
| 32 | + needs: check-workflows |
| 33 | + uses: MetaMask/action-security-code-scanner/.github/workflows/security-scan.yml@v2 |
| 34 | + with: |
| 35 | + scanner-ref: v2 |
| 36 | + paths-ignored: | |
| 37 | + node_modules/ |
| 38 | + .skills-cache/ |
| 39 | + **/*.patch |
| 40 | + **/fixtures/ |
| 41 | + secrets: |
| 42 | + project-metrics-token: ${{ secrets.SECURITY_SCAN_METRICS_TOKEN }} |
| 43 | + slack-webhook: ${{ secrets.APPSEC_BOT_SLACK_WEBHOOK }} |
| 44 | + permissions: |
| 45 | + actions: read |
| 46 | + contents: read |
| 47 | + security-events: write |
| 48 | + |
| 49 | + lint-build-test: |
| 50 | + name: Lint, build, and test |
| 51 | + needs: check-workflows |
| 52 | + uses: ./.github/workflows/lint-build-test.yml |
| 53 | + |
| 54 | + is-release: |
| 55 | + name: Determine whether this is a release merge commit |
| 56 | + needs: lint-build-test |
| 57 | + if: github.event_name == 'push' |
| 58 | + runs-on: ubuntu-latest |
| 59 | + outputs: |
| 60 | + IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }} |
| 61 | + steps: |
| 62 | + - id: is-release |
| 63 | + uses: MetaMask/action-is-release@v2 |
| 64 | + with: |
| 65 | + commit-starts-with: ${{ vars.RELEASE_COMMIT_PREFIX }} |
| 66 | + |
| 67 | + publish-release: |
| 68 | + name: Publish release |
| 69 | + needs: is-release |
| 70 | + if: needs.is-release.outputs.IS_RELEASE == 'true' |
| 71 | + permissions: |
| 72 | + contents: write |
| 73 | + uses: ./.github/workflows/publish-release.yml |
| 74 | + secrets: |
| 75 | + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} |
| 76 | + SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} |
| 77 | + |
| 78 | + all-jobs-complete: |
| 79 | + name: All jobs complete |
| 80 | + runs-on: ubuntu-latest |
| 81 | + needs: |
| 82 | + - analyse-code |
| 83 | + - lint-build-test |
| 84 | + outputs: |
| 85 | + passed: ${{ steps.set-output.outputs.passed }} |
| 86 | + steps: |
| 87 | + - name: Set passed output |
| 88 | + id: set-output |
| 89 | + run: echo "passed=true" >> "$GITHUB_OUTPUT" |
| 90 | + |
| 91 | + all-jobs-pass: |
| 92 | + name: All jobs pass |
| 93 | + if: ${{ always() }} |
| 94 | + runs-on: ubuntu-latest |
| 95 | + needs: |
| 96 | + - all-jobs-complete |
| 97 | + steps: |
| 98 | + - name: Check that all jobs have passed |
| 99 | + env: |
| 100 | + PASSED: ${{ needs.all-jobs-complete.outputs.passed }} |
| 101 | + run: | |
| 102 | + if [[ "$PASSED" != "true" ]]; then |
| 103 | + exit 1 |
| 104 | + fi |
0 commit comments