forked from jl777/SuperNET
-
Notifications
You must be signed in to change notification settings - Fork 97
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(CI): handle remote files in a safer way (#2217)
This commit updates GHA runners to use locked scripts rather than always using the latest one from the master branch. It also adds a new GHA helper/plugin to easily download files and verify their checksums.
- Loading branch information
1 parent
7ef08e4
commit 6dc3c7d
Showing
3 changed files
with
89 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
name: "Download and verify remote files" | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Download (Unix) | ||
if: runner.os != 'Windows' | ||
shell: bash | ||
run: curl -L -o ${{ inputs.output_file }} ${{ inputs.url }} | ||
|
||
- name: Download (Windows) | ||
if: runner.os == 'Windows' | ||
shell: powershell | ||
run: Invoke-WebRequest -Uri ${{ inputs.url }} -OutFile ${{ inputs.output_file }} | ||
|
||
- name: Verify (Unix) | ||
if: runner.os != 'Windows' | ||
shell: bash | ||
run: | | ||
if [[ "$RUNNER_OS" == "macOS" ]]; then | ||
echo "${{ inputs.checksum }} *${{ inputs.output_file }}" | shasum -a 256 -c | ||
else | ||
echo "${{ inputs.checksum }} ${{ inputs.output_file }}" | sha256sum -c | ||
fi | ||
- name: Verify (Windows) | ||
if: runner.os == 'Windows' | ||
shell: powershell | ||
run: | | ||
$expectedChecksum = "${{ inputs.checksum }}" | ||
$actualChecksum = (Get-FileHash -Path "${{ inputs.output_file }}" -Algorithm SHA256).Hash | ||
if ($expectedChecksum -ne $actualChecksum) { | ||
Write-Output "Checksum did not match! Expected: $expectedChecksum, Found: $actualChecksum" | ||
exit 1 | ||
} | ||
inputs: | ||
url: | ||
description: "URL of the remote file." | ||
required: true | ||
output_file: | ||
description: "Output path." | ||
required: true | ||
checksum: | ||
description: "Expected checksum of the downloaded file." | ||
required: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters