Skip to content

Commit 1fca2e2

Browse files
committed
Add support for direct command execution with witness
1 parent 24d40d5 commit 1fca2e2

File tree

4 files changed

+356
-35
lines changed

4 files changed

+356
-35
lines changed

.github/workflows/test.yml

Lines changed: 106 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@ on:
55
branches: [ main ]
66
pull_request:
77
branches: [ main ]
8+
9+
permissions:
10+
id-token: write # This is required for requesting the JWT
11+
contents: read # This is required for actions/checkout
812

913
jobs:
1014
test-basic:
@@ -85,4 +89,105 @@ jobs:
8589
uses: actions/upload-artifact@v4
8690
with:
8791
name: attestation-files
88-
path: ./multi-attestation.json
92+
path: ./multi-attestation.json
93+
94+
test-sigstore-archivista:
95+
runs-on: ubuntu-latest
96+
steps:
97+
- name: Checkout repository
98+
uses: actions/checkout@v3
99+
100+
- name: Setup Node.js
101+
uses: actions/setup-node@v3
102+
with:
103+
node-version: '16'
104+
105+
- name: Install dependencies
106+
run: npm ci
107+
108+
- name: Test with Sigstore and Archivista
109+
id: sigstore-attestation
110+
uses: ./
111+
with:
112+
# Action to run
113+
action-ref: "actions/hello-world-javascript-action@main"
114+
input-who-to-greet: "Sigstore"
115+
116+
# Witness configuration
117+
step: test-sigstore
118+
attestations: "environment git github slsa"
119+
attestor-slsa-export: "true"
120+
enable-sigstore: "true"
121+
enable-archivista: "true"
122+
outfile: "./sigstore-attestation.json"
123+
124+
- name: Check GitOID output
125+
run: |
126+
if [[ -n "${{ steps.sigstore-attestation.outputs.git_oid }}" ]]; then
127+
echo "GitOID: ${{ steps.sigstore-attestation.outputs.git_oid }}"
128+
echo "Attestation succeeded with Sigstore and Archivista"
129+
else
130+
echo "No GitOID returned - this might be expected in PR builds without proper credentials"
131+
fi
132+
133+
- name: Check attestation file
134+
run: |
135+
if [[ -f "./sigstore-attestation.json" ]]; then
136+
echo "Sigstore attestation created successfully"
137+
jq . "./sigstore-attestation.json" | head -n 20
138+
else
139+
echo "Sigstore attestation file not found!"
140+
exit 1
141+
fi
142+
143+
- name: Upload sigstore attestation as artifact
144+
uses: actions/upload-artifact@v4
145+
with:
146+
name: sigstore-attestation
147+
path: ./sigstore-attestation.json
148+
149+
test-direct-command:
150+
runs-on: ubuntu-latest
151+
steps:
152+
- name: Checkout repository
153+
uses: actions/checkout@v3
154+
155+
- name: Setup Node.js
156+
uses: actions/setup-node@v3
157+
with:
158+
node-version: '16'
159+
160+
- name: Install dependencies
161+
run: npm ci
162+
163+
- name: Test direct command
164+
id: direct-command
165+
uses: ./
166+
with:
167+
# Direct command to run
168+
command: "echo hello > hello.txt"
169+
170+
# Witness configuration
171+
step: "direct-command"
172+
attestations: "command environment"
173+
outfile: "./direct-command.json"
174+
175+
- name: Check command output
176+
run: |
177+
if [ -f "hello.txt" ]; then
178+
echo "Command output:"
179+
cat hello.txt
180+
else
181+
echo "Command output file not found!"
182+
exit 1
183+
fi
184+
185+
- name: Check attestation file
186+
run: |
187+
if [[ -f "./direct-command.json" ]]; then
188+
echo "Direct command attestation created successfully"
189+
jq . "./direct-command.json" | head -n 20
190+
else
191+
echo "Direct command attestation file not found!"
192+
exit 1
193+
fi

README.md

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@ A GitHub Action that downloads and executes another GitHub Action with Witness a
44

55
## Usage
66

7+
### Running a GitHub Action with Witness Attestation
8+
79
```yaml
810
name: Example Workflow
911
on: [push, pull_request]
@@ -30,6 +32,32 @@ jobs:
3032
archivista-server: "https://archivista.example.com"
3133
```
3234
35+
### Running a Direct Command with Witness Attestation
36+
37+
```yaml
38+
name: Example Workflow
39+
on: [push, pull_request]
40+
41+
jobs:
42+
build:
43+
runs-on: ubuntu-latest
44+
steps:
45+
- name: Checkout
46+
uses: actions/checkout@v3
47+
48+
- name: Run Command with Witness Attestation
49+
id: command-attestation
50+
uses: testifysec/action-wrapper@v4
51+
with:
52+
# Command to run
53+
command: "echo hello > hello.txt"
54+
55+
# Witness configuration
56+
step: "command-step"
57+
attestations: "command environment git"
58+
enable-sigstore: "true"
59+
```
60+
3361
## How It Works
3462
3563
This action combines the functionality of a GitHub Action wrapper with Witness attestation:
@@ -49,11 +77,14 @@ This action combines the functionality of a GitHub Action wrapper with Witness a
4977
5078
## Inputs
5179
52-
### Action Reference
80+
### Action or Command
5381
5482
| Input | Description | Required | Default |
5583
|-------|-------------|----------|---------|
56-
| `action-ref` | Reference to the nested action (e.g., owner/repo@ref) | Yes | |
84+
| `action-ref` | Reference to the nested action (e.g., owner/repo@ref) | No¹ | |
85+
| `command` | Command to run with Witness (use this or action-ref) | No¹ | |
86+
87+
¹ Either `action-ref` or `command` must be provided
5788

5889
### Witness Installation
5990

action.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
name: "TestifySec Action Wrapper with Witness"
22
description: "Downloads and executes another GitHub Action with Witness attestation"
33
inputs:
4-
# Action Reference
4+
# Action or Command
55
action-ref:
66
description: "Reference to the nested action (e.g., owner/repo@ref)"
7-
required: true
7+
required: false
8+
command:
9+
description: "Command to run with Witness (use this or action-ref)"
10+
required: false
811

912
# Witness Installation
1013
witness-version:

0 commit comments

Comments
 (0)