Skip to content

Commit 3469bf9

Browse files
committed
prepare for CI testing
Signed-off-by: William Woodruff <[email protected]>
1 parent 1753a22 commit 3469bf9

3 files changed

Lines changed: 67 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
name: Test
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
concurrency:
11+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
12+
cancel-in-progress: true
13+
14+
permissions: {}
15+
16+
env:
17+
STAGING_PYX_UPLOAD_URL: https://astral-sh-staging-api.pyx.dev/v1/upload/pyx-auth-action/main
18+
PYX_API_URL: https://astral-sh-staging-api.pyx.dev
19+
20+
jobs:
21+
id-token:
22+
name: "Obtain cursed OIDC token"
23+
runs-on: ubuntu-latest
24+
permissions: {}
25+
outputs:
26+
id-token: ${{ steps.beacon.outputs.id-token }}
27+
28+
steps:
29+
- name: Obtain cursed OIDC token
30+
uses: sigstore-conformance/extremely-dangerous-public-oidc-beacon@4a8befcc16064dac9e97f210948d226e5c869bdc # v1.0.0
31+
32+
- name: Set output
33+
id: beacon
34+
run: |
35+
echo "id-token=$(cat ./oidc-token.txt)" >> ${GITHUB_OUTPUT}
36+
37+
all-tests-pass:
38+
name: "Ensure all selftests pass"
39+
if: always()
40+
41+
needs:
42+
- id-token
43+
44+
runs-on: ubuntu-latest
45+
46+
steps:
47+
- name: Ensure all selftests passed
48+
uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
49+
with:
50+
jobs: ${{ toJSON(needs) }}

action.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ def _get_input(name: str) -> str | None:
2323
"""
2424
Get an action input from the environment, or `None` if not set.
2525
"""
26-
env = f"ATTEST_ACTION_INPUT_{name.upper()}"
26+
env = f"ATTEST_ACTION_INPUT_{name.upper().replace('-', '_')}"
2727
return os.getenv(env)
2828

2929

@@ -146,7 +146,11 @@ def main() -> None:
146146

147147
dists = _collect_dists(path_patterns)
148148

149-
id_token = _get_id_token()
149+
if id_token := _get_input("id-token"):
150+
id_token = oidc.IdentityToken(raw_token=id_token)
151+
else:
152+
id_token = _get_id_token()
153+
150154
overwrite = _get_input("overwrite") == "true"
151155

152156
_attest(dists, id_token, overwrite=overwrite)

action.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,15 @@ inputs:
1111
description: Whether to overwrite existing attestations if they already exist.
1212
required: false
1313
default: "false"
14+
id-token:
15+
description: >
16+
An OIDC identity token to use for signing attestations. If not provided,
17+
the ambient token will be used.
18+
19+
**IMPORTANT**: This input is an implementation detail. End users should
20+
never need to set it.
21+
required: false
22+
default: ""
1423

1524
outputs: {}
1625

@@ -26,3 +35,5 @@ runs:
2635
shell: bash
2736
env:
2837
ATTEST_ACTION_INPUT_PATHS: ${{ inputs.paths }}
38+
ATTEST_ACTION_INPUT_OVERWRITE: ${{ inputs.overwrite }}
39+
ATTEST_ACTION_INPUT_ID_TOKEN: ${{ inputs.id-token }}

0 commit comments

Comments
 (0)