-
Notifications
You must be signed in to change notification settings - Fork 15
77 lines (75 loc) · 2.26 KB
/
build.yml
File metadata and controls
77 lines (75 loc) · 2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
name: build
on:
pull_request: {}
workflow_dispatch: {}
permissions:
actions: none
attestations: none
checks: none
contents: none
deployments: none
discussions: none
id-token: none
issues: none
models: none
packages: none
pages: none
pull-requests: none
repository-projects: none
security-events: none
statuses: none
jobs:
build:
permissions:
actions: write # upload-artifact when self-mutation is detected
contents: read
runs-on: ubuntu-latest
outputs:
self_mutation_happened: ${{ steps.self_mutation.outputs.self_mutation_happened }}
env:
CI: "true"
MISE_EXPERIMENTAL: "1"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AQUA_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# Keep secret and dependency scanning enabled in CI; only disable the
# remaining tools that are intentionally skipped here.
MISE_DISABLE_TOOLS: "aqua:aquasecurity/trivy,grype,semgrep"
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 1 # shallow clone
persist-credentials: false
- name: Install mise
uses: jdx/mise-action@v3.6.2
with:
cache: true
- name: Setup Node.js
uses: actions/setup-node@v5
with:
node-version: 22.x
- name: Install dependencies
run: mise run install
- name: build
run: mise run build
- name: Find mutations
id: self_mutation
run: |-
git add .
git diff --staged --patch --exit-code > repo.patch || echo "self_mutation_happened=true" >> $GITHUB_OUTPUT
shell: bash
working-directory: ./
- name: Upload patch
if: steps.self_mutation.outputs.self_mutation_happened
uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v4.4.0
with:
name: repo.patch
path: repo.patch
overwrite: true
- name: Fail build on mutation
if: steps.self_mutation.outputs.self_mutation_happened
run: |-
echo "::error::Files were changed during build (see build log). Please run the build locally and commit the changes."
cat repo.patch
exit 1