Skip to content

Commit

Permalink
Allow multiple artifacts to exist (#102)
Browse files Browse the repository at this point in the history
* Allow multiple artifacts to exist

I'm planning to publish the token in GitHub Pages soon. The only
realistic way to do that is to use actions/upload-pages-artifact
and then actions/deploy-pages -- the currently uploaded artifact
is not usable for this.

This commit makes the script not fail if there are multiple
artifacts, but still uses the same artifact as before. This makes it
possible to start publishing a new 'github-pages' artifact without
immediately breaking this script.

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>

* refactor oidc artifact id lookup

---------

Signed-off-by: Jussi Kukkonen <jkukkonen@google.com>
  • Loading branch information
jku authored Oct 6, 2023
1 parent 2a930eb commit 614f4c9
Showing 1 changed file with 4 additions and 12 deletions.
16 changes: 4 additions & 12 deletions test/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,18 +137,10 @@ def identity_token(pytestconfig) -> str:
resp.raise_for_status()

resp_json = resp.json()
artifacts = resp_json["artifacts"]
if len(artifacts) != 1:
raise OidcTokenError(
f"Found unexpected number of artifacts on OIDC beacon run: {artifacts}"
)

oidc_artifact = artifacts[0]
if oidc_artifact["name"] != "oidc-token":
raise OidcTokenError(
f"Found unexpected artifact on OIDC beacon run: {oidc_artifact['name']}"
)
artifact_id = oidc_artifact["id"]
try:
artifact_id = next(a["id"] for a in resp_json["artifacts"] if a["name"] == "oidc-token")
except StopIteration:
raise OidcTokenError("Artifact 'oidc-token' could not be found")

# Download the OIDC token artifact and unzip the archive.
resp = session.get(
Expand Down

0 comments on commit 614f4c9

Please sign in to comment.