Skip to content

Commit

Permalink
ci: add zizmor for github action security (#284)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sysix authored Dec 17, 2024
1 parent 2614c15 commit 2f77f32
Show file tree
Hide file tree
Showing 10 changed files with 83 additions and 15 deletions.
2 changes: 1 addition & 1 deletion .github/renovate.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
"extends": ["github>Boshen/renovate"],
"extends": ["github>Boshen/renovate", "helpers:pinGitHubActionDigests"],
"packageRules": [
{
"groupName": "npm packages",
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false

- uses: ./.github/actions/pnpm

Expand Down
14 changes: 10 additions & 4 deletions .github/workflows/bump_oxlint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ jobs:
bump:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false # should be fine, we give another token for PR creation

- uses: ./.github/actions/pnpm

- name: Generate version ${{ inputs.version }}
env:
OXLINT_VERSION: ${{ inputs.version }}
run: |
pnpm install oxlint@${{ inputs.version }}
pnpm run clone ${{ inputs.version }}
pnpm install oxlint@${OXLINT_VERSION}
pnpm run clone ${OXLINT_VERSION}
pnpm run generate # Generate rules from source code
pnpm run format # run prettier over it
Expand All @@ -30,7 +34,9 @@ jobs:
run: pnpm run test -u # Update test snapshots

- name: Bump oxlint rules
run: npm version ${{ inputs.version }} --no-git-tag-version
env:
OXLINT_VERSION: ${{ inputs.version }}
run: npm version ${OXLINT_VERSION} --no-git-tag-version

- uses: peter-evans/create-pull-request@v7
with:
Expand Down
41 changes: 41 additions & 0 deletions .github/workflows/ci_security.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: GitHub Actions Security Analysis

on:
workflow_dispatch:
pull_request:
types: [opened, synchronize]
paths:
- '.github/workflows/**'
push:
branches:
- main
- 'renovate/**'
paths:
- '.github/workflows/**'

jobs:
zizmor:
name: zizmor
runs-on: ubuntu-latest
permissions:
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false

- uses: taiki-e/install-action@8c39981484df4e7ba41af8e8e078ac546d5e1b11 # v2.46.8
with:
tool: zizmor

- name: Run zizmor
run: zizmor --format sarif . > results.sarif
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Upload SARIF file
uses: github/codeql-action/upload-sarif@df409f7d9260372bd5f19e5b04e83cb3c43714ae # v3
with:
sarif_file: results.sarif
category: zizmor
5 changes: 4 additions & 1 deletion .github/workflows/format.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ jobs:
format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false

- name: Run Format (prettier)
run: npx prettier . --check
5 changes: 4 additions & 1 deletion .github/workflows/generate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ jobs:
generate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false

- uses: ./.github/actions/pnpm

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false

- uses: ./.github/actions/pnpm

Expand Down
11 changes: 7 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,24 +12,27 @@ jobs:
contents: write
id-token: write # for `npm publish --provenance`
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
fetch-depth: 0
persist-credentials: false

- uses: ./.github/actions/pnpm

- name: Build
run: pnpm run build

- name: Extract version from commit message
env:
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
run: |
VERSION=$(echo "${{ github.event.head_commit.message }}" | grep -oP 'release: \Kv[0-9]+\.[0-9]+\.[0-9]+')
VERSION=$(echo "${COMMIT_MESSAGE}" | grep -oP 'release: \Kv[0-9]+\.[0-9]+\.[0-9]+')
echo "VERSION=$VERSION" >> $GITHUB_ENV
- name: Create and push tag
run: |
git tag ${{ env.VERSION }}
git push origin ${{ env.VERSION }}
git tag ${VERSION}
git push origin ${VERSION}
- run: npx changelogithub
continue-on-error: true
Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false

- uses: ./.github/actions/pnpm

Expand Down
5 changes: 4 additions & 1 deletion .github/workflows/type-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@ jobs:
type-check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Checkout repository
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
persist-credentials: false

- uses: ./.github/actions/pnpm

Expand Down

0 comments on commit 2f77f32

Please sign in to comment.