Skip to content

Commit

Permalink
action: handle slashes in ref names (#63)
Browse files Browse the repository at this point in the history
* action: handle slashes in ref names

Fixes #62.

Signed-off-by: William Woodruff <william@trailofbits.com>

* requirements: bump sigstore

Signed-off-by: William Woodruff <william@trailofbits.com>

---------

Signed-off-by: William Woodruff <william@trailofbits.com>
  • Loading branch information
woodruffw committed Apr 24, 2023
1 parent 9247cf3 commit 64c04b5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion action.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ def _download_ref_asset(ext):
repo = os.getenv("GITHUB_REPOSITORY")
ref = os.getenv("GITHUB_REF")

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

artifact = Path(f"/tmp/{ref_name_normalized}.{ext}")

# GitHub supports /:org/:repo/archive/:ref<.tar.gz|.zip>.
r = requests.get(f"https://github.com/{repo}/archive/{ref}.{ext}", stream=True)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
sigstore ~= 1.1
sigstore ~= 1.1.2
requests ~= 2.28

0 comments on commit 64c04b5

Please sign in to comment.