Skip to content

Commit 64c04b5

Browse files
authored
action: handle slashes in ref names (#63)
* action: handle slashes in ref names Fixes #62. Signed-off-by: William Woodruff <[email protected]> * requirements: bump sigstore Signed-off-by: William Woodruff <[email protected]> --------- Signed-off-by: William Woodruff <[email protected]>
1 parent 9247cf3 commit 64c04b5

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

action.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,12 @@ def _download_ref_asset(ext):
6262
repo = os.getenv("GITHUB_REPOSITORY")
6363
ref = os.getenv("GITHUB_REF")
6464

65-
artifact = Path(f"/tmp/{os.getenv('GITHUB_REF_NAME')}.{ext}")
65+
# NOTE: Branch names often have `/` in them (e.g. `feat/some-name`),
66+
# which would break the artifact path we construct below.
67+
# We "fix" these by lossily replacing all `/` with `-`.
68+
ref_name_normalized = os.getenv("GITHUB_REF_NAME").replace("/", "-")
69+
70+
artifact = Path(f"/tmp/{ref_name_normalized}.{ext}")
6671

6772
# GitHub supports /:org/:repo/archive/:ref<.tar.gz|.zip>.
6873
r = requests.get(f"https://github.com/{repo}/archive/{ref}.{ext}", stream=True)

requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
sigstore ~= 1.1
1+
sigstore ~= 1.1.2
22
requests ~= 2.28

0 commit comments

Comments
 (0)