Skip to content

Commit 7803a84

Browse files
committed
allow overriding git ref when creating contents download url
1 parent a571c76 commit 7803a84

4 files changed

Lines changed: 5 additions & 3 deletions

File tree

.github/workflows/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,8 @@ jobs:
150150
- name: Scan local random-80mb-file
151151
id: scan_local_80mb
152152
uses: ./
153+
env:
154+
GIT_REF: ${{ steps.create_temp_branch.outputs.branch_name }}
153155
with:
154156
local-file-path: test-data/random-80mb-file
155157
api-key: ${{ secrets.ATTACHMENTAV_API_KEY }}

dist/index.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32961,7 +32961,7 @@ async function getContentsDownloadUrl(localFilePath, token) {
3296132961
const { owner, repo } = context.repo;
3296232962
// Remove leading slash if present
3296332963
const cleanPath = localFilePath.startsWith('/') ? localFilePath.slice(1) : localFilePath;
32964-
const query = `ref=${encodeURIComponent(context.ref.replace('refs/heads/', ''))}`;
32964+
const query = `ref=${encodeURIComponent(process.env.GIT_REF || context.ref)}`;
3296532965
const url = `https://api.github.com/repos/${owner}/${repo}/contents/${cleanPath}?${query}`;
3296632966
debug(`using download url ${url}`);
3296732967
try {

dist/index.mjs.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/github.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ export async function getContentsDownloadUrl(localFilePath: string, token: strin
1111

1212
// Remove leading slash if present
1313
const cleanPath = localFilePath.startsWith('/') ? localFilePath.slice(1) : localFilePath;
14-
const query = `ref=${encodeURIComponent(github.context.ref.replace('refs/heads/', ''))}`;
14+
const query = `ref=${encodeURIComponent(process.env.GIT_REF || github.context.ref)}`;
1515
const url = `https://api.github.com/repos/${owner}/${repo}/contents/${cleanPath}?${query}`;
1616

1717
core.debug(`using download url ${url}`);

0 commit comments

Comments
 (0)