Skip to content

Commit ed7a67d

Browse files
authored
feat(ci): Adds chainloop to codeql pipeline (#711)
Signed-off-by: Javier Rodriguez <[email protected]>
1 parent f8360a0 commit ed7a67d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

.github/workflows/codeql.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,29 @@ jobs:
2020
actions: read
2121
contents: read
2222
security-events: write
23+
env:
24+
CHAINLOOP_VERSION: 0.83.0
25+
CHAINLOOP_ROBOT_ACCOUNT: ${{ secrets.CHAINLOOP_ROBOT_ACCOUNT_CODEQL }}
2326

2427
strategy:
2528
fail-fast: false
2629
matrix:
2730
language: ["go"]
2831

2932
steps:
33+
- name: Install Chainloop
34+
if: ${{ github.event_name != 'pull_request' }}
35+
run: |
36+
curl -sfL https://raw.githubusercontent.com/chainloop-dev/chainloop/01ad13af08950b7bfbc83569bea207aeb4e1a285/docs/static/install.sh | bash -s -- --version v${{ env.CHAINLOOP_VERSION }}
37+
3038
- name: Checkout repository
3139
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
3240

41+
- name: Initialize Attestation
42+
if: ${{ github.event_name != 'pull_request' }}
43+
run: |
44+
chainloop attestation init
45+
3346
- name: Set up Go
3447
uses: actions/setup-go@6edd4406fa81c3da01a34fa6f6343087c207a568 # v3.5.0
3548
with:
@@ -45,6 +58,30 @@ jobs:
4558
uses: github/codeql-action/autobuild@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2.21.8
4659

4760
- name: Perform CodeQL Analysis
61+
id: codeqlresults
4862
uses: github/codeql-action/analyze@6a28655e3dcb49cb0840ea372fd6d17733edd8a4 # v2.21.8
4963
with:
5064
category: "/language:${{matrix.language}}"
65+
66+
- name: Add Attestation (Sarif results)
67+
run: |
68+
chainloop attestation add --name sarif-results --value ${{steps.codeqlresults.outputs.sarif-output}}/go.sarif
69+
70+
- name: Finish and Record Attestation
71+
if: ${{ success() && github.event_name != 'pull_request' }}
72+
run: |
73+
chainloop attestation status --full
74+
chainloop attestation push --key env://CHAINLOOP_SIGNING_KEY
75+
env:
76+
CHAINLOOP_SIGNING_PASSWORD: ${{ secrets.COSIGN_PASSWORD }}
77+
CHAINLOOP_SIGNING_KEY: ${{ secrets.COSIGN_KEY }}
78+
79+
- name: Mark attestation as failed
80+
if: ${{ failure() && github.event_name != 'pull_request' }}
81+
run: |
82+
chainloop attestation reset
83+
84+
- name: Mark attestation as cancelled
85+
if: ${{ cancelled() && github.event_name != 'pull_request' }}
86+
run: |
87+
chainloop attestation reset --trigger cancellation

0 commit comments

Comments
 (0)