Skip to content

security: harden GitHub workflows against fork PR attacks #185

security: harden GitHub workflows against fork PR attacks

security: harden GitHub workflows against fork PR attacks #185

name: Continuous integration
concurrency:
cancel-in-progress: true
group: pull-request-${{ github.event.pull_request.number }}
permissions:
contents: read
jobs:
# Stage 1: build, dependency-review
build:
name: Build
if: github.event.pull_request.head.repo.full_name == github.repository
environment: continuous-integration
runs-on: ubuntu-latest
services:
datadog-agent: &datadog-agent
image: datadog/agent:latest
env:
DD_API_KEY: ${{ secrets.DATADOG_API_KEY }}
DD_ENV: ci
DD_HOSTNAME: none
DD_INSIDE_CI: true
ports:
- 8126:8126
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Build
uses: ./.github/actions/build
with:
environment: staging
dependency-review:
name: Dependency review
if: github.event.pull_request.head.repo.full_name == github.repository
environment: continuous-integration
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Review
uses: actions/dependency-review-action@v4
# Stage 2: lighthouse, test, webhint
lighthouse:
name: Lighthouse
if: github.event.pull_request.head.repo.full_name == github.repository
environment: continuous-integration
needs: build
runs-on: ubuntu-latest
services:
datadog-agent: *datadog-agent
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Lighthouse
uses: ./.github/actions/lighthouse-ci
test:
name: Test
if: github.event.pull_request.head.repo.full_name == github.repository
environment: continuous-integration
needs: build
runs-on: ubuntu-latest
services:
datadog-agent: *datadog-agent
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Test
uses: ./.github/actions/test
webhint:
name: Webhint
if: github.event.pull_request.head.repo.full_name == github.repository
environment: continuous-integration
needs: build
runs-on: ubuntu-latest
services:
datadog-agent: *datadog-agent
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Audit
uses: ./.github/actions/webhint-ci
# Stage 3: sentry-prevent
sentry-prevent:
name: Sentry Prevent
if: github.event.pull_request.head.repo.full_name == github.repository
environment: continuous-integration
needs: test
runs-on: ubuntu-latest
permissions:
contents: read
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Scan
uses: ./.github/actions/sentry-prevent
on:
pull_request: