forked from jl777/SuperNET
-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement download & checksum plugin for CI
Signed-off-by: onur-ozkan <[email protected]>
- Loading branch information
1 parent
7cb6d1a
commit 5d94ec1
Showing
3 changed files
with
84 additions
and
8 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 --check | ||
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