Skip to content

Commit

Permalink
fix: Use GitHub personal access token to retrieve artifacts.
Browse files Browse the repository at this point in the history
  • Loading branch information
na2axl committed Oct 6, 2024
1 parent 03c4673 commit 4b26b09
Show file tree
Hide file tree
Showing 5 changed files with 30 additions and 7 deletions.
7 changes: 6 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,12 @@ jobs:
x64-osx
x64-linux
version: nightly
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Print Output
id: output
run: echo "${{ steps.test-action.outputs.time }}"
run: |
echo "${{ steps.test-action.outputs.x64_windows_nightly }}"
echo "${{ steps.test-action.outputs.x64_osx_nightly }}"
echo "${{ steps.test-action.outputs.x64_linux_nightly }}"
2 changes: 1 addition & 1 deletion badges/coverage.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 8 additions & 2 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

16 changes: 14 additions & 2 deletions src/download.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,16 @@ async function downloadNightly(platforms: Platform[]): Promise<void> {
const artifactsUrl =
'https://api.github.com/repos/AmplitudeAudio/sdk/actions/artifacts'

let headers: Record<string, string> = {}

if (process.env.GITHUB_TOKEN !== undefined) {
headers = {
Authorization: `token ${process.env.GITHUB_TOKEN}`
}
}

core.debug('Retrieving artifacts from GitHub Actions')
const response = await fetch(artifactsUrl)
const response = await fetch(artifactsUrl, { headers })
if (!response.ok) {
throw new Error(`Failed to fetch artifacts: ${response.status}`)
}
Expand All @@ -44,7 +52,11 @@ async function downloadNightly(platforms: Platform[]): Promise<void> {
}

const downloadUrl = artifact.archive_download_url
const downloadedPath = await tc.downloadTool(downloadUrl)
const downloadedPath = await tc.downloadTool(
downloadUrl,
'./artifacts',
headers.Authorization
)
const extractedFolder = await tc.extract7z(downloadedPath)

core.addPath(extractedFolder)
Expand Down

0 comments on commit 4b26b09

Please sign in to comment.