name: Main on: push: branches: [main] pull_request: merge_group: concurrency: group: ${{ github.workflow }}-${{ github.ref == 'refs/heads/main' && github.sha || github.ref }} cancel-in-progress: ${{ !contains(github.ref, 'refs/heads/main') }} permissions: contents: read jobs: check-skip-merge-queue: name: Check if pull request can skip merge queue runs-on: ubuntu-latest permissions: contents: read pull-requests: read outputs: skip-merge-queue: ${{ steps.check-skip-merge-queue.outputs.up-to-date }} steps: - name: Check pull request merge queue status id: check-skip-merge-queue if: github.event_name == 'merge_group' uses: MetaMask/github-tools/.github/actions/check-skip-merge-queue@v1 check-workflows: name: Check workflows needs: - check-skip-merge-queue if: github.event_name != 'merge_group' || needs.check-skip-merge-queue.outputs.skip-merge-queue != 'true' runs-on: ubuntu-latest permissions: contents: read steps: - uses: actions/checkout@v7 with: persist-credentials: false - name: Download actionlint id: download-actionlint run: bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/914e7df21a07ef503a81201c76d2b11c789d3fca/scripts/download-actionlint.bash) 1.7.12 shell: bash - name: Check workflow files run: | "$ACTIONLINT" -color shell: bash env: ACTIONLINT: ${{ steps.download-actionlint.outputs.executable }} analyse-code: name: Analyse code needs: check-workflows uses: MetaMask/action-security-code-scanner/.github/workflows/security-scan.yml@v2 with: scanner-ref: v2 paths-ignored: | .storybook/ **/__snapshots__/ **/*.snap **/*.stories.js **/*.stories.tsx **/*.test.browser.ts* **/*.test.js* **/*.test.ts* **/fixtures/ **/mocks/ **/test*/ docs/ e2e/ merged-packages/ node_modules/ storybook/ test*/ secrets: project-metrics-token: ${{ secrets.SECURITY_SCAN_METRICS_TOKEN }} slack-webhook: ${{ secrets.APPSEC_BOT_SLACK_WEBHOOK }} permissions: actions: read contents: read security-events: write lint-build-test: name: Lint, build, and test needs: check-workflows uses: ./.github/workflows/lint-build-test.yml deploy-platform-api-docs: name: Deploy Platform API Docs needs: lint-build-test if: github.ref == 'refs/heads/main' && github.event_name == 'push' permissions: contents: read id-token: write uses: ./.github/workflows/deploy-platform-api-docs.yml check-release: name: Check release needs: check-workflows runs-on: ubuntu-latest permissions: contents: read pull-requests: write steps: - name: Checkout repository uses: actions/checkout@v7 with: fetch-depth: 0 persist-credentials: false - name: Check release if: github.event_name != 'push' uses: ./.github/actions/check-release with: commit-starts-with: ${{ vars.RELEASE_COMMIT_PREFIX }} is-release: name: Determine whether this is a release merge commit needs: lint-build-test if: github.event_name == 'push' runs-on: ubuntu-latest outputs: IS_RELEASE: ${{ steps.is-release.outputs.IS_RELEASE }} steps: - id: is-release uses: MetaMask/action-is-release@v2 with: commit-starts-with: ${{ vars.RELEASE_COMMIT_PREFIX }} publish-release: name: Publish release needs: is-release if: needs.is-release.outputs.IS_RELEASE == 'true' permissions: contents: write id-token: write uses: ./.github/workflows/publish-release.yml secrets: NPM_TOKEN: ${{ secrets.NPM_TOKEN }} SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} all-jobs-pass: name: All jobs pass if: ${{ always() }} runs-on: ubuntu-latest needs: - analyse-code - check-release - lint-build-test - check-skip-merge-queue env: RESULTS: ${{ toJSON(needs.*.result) }} SKIP_MERGE_QUEUE: ${{ needs.check-skip-merge-queue.outputs.skip-merge-queue }} steps: - name: Check the results of the other jobs run: | if [[ "$SKIP_MERGE_QUEUE" == "true" ]]; then exit 0 fi echo "$RESULTS" | jq -e 'all(. == "success")'