-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First simple version of Github Action
- Loading branch information
0 parents
commit 37b8669
Showing
332 changed files
with
73,025 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# Verify File Checksum action | ||
|
||
This action verifies the checksum of a given file. If it passes, the Github Action passes. | ||
|
||
## Inputs | ||
|
||
### `file` | ||
|
||
**Required** The file to check. If it's an URL, use the [`file:`](https://en.wikipedia.org/wiki/File_URI_scheme) protocol. | ||
|
||
### `checksum` | ||
|
||
**Required** The expected (hexadecimal) checksum of the given file. | ||
|
||
### `algorithm` | ||
|
||
**Required** The algorithm that has been used for calculating the checksum. Run `openssl list-message-digest-algorithms` in your terminal to check all available algorithms. Examples: `MD5`, `SHA512`, `DSA-SHA1`. | ||
|
||
## Outputs | ||
|
||
### `verify-result` | ||
|
||
Does the checksum match with the given file. | ||
|
||
## Example usage | ||
|
||
```yaml | ||
uses: actions/[email protected] | ||
with: | ||
file: 'file://assets.iec.ch/public/tc57/IEC_61850-6.2018.SCL.2007B4.full.zip' | ||
checksum: 'd61da94836ff974fbd781ad1bc967039' | ||
algorithm: 'MD5' | ||
``` |
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,19 @@ | ||
name: 'Verify File Checksum' | ||
description: 'Verify the checksum of a given file. If it passes, the Github Action passes.' | ||
inputs: | ||
file: | ||
description: 'The file to check.' | ||
required: true | ||
checksum: | ||
description: 'The expected checksum of the given file.' | ||
required: true | ||
algorithm: | ||
description: 'The algorithm that has been used for calculating the checksum.' | ||
required: true | ||
default: 'MD5' | ||
outputs: | ||
verify-result: | ||
description: 'Does the checksum match with the given file.' | ||
runs: | ||
using: 'node12' | ||
main: 'index.js' |
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,27 @@ | ||
const core = require('@actions/core'); | ||
const github = require('@actions/github'); | ||
const crypto = require('crypto'); | ||
const fs = require('fs') | ||
|
||
try { | ||
// Create a Hash based on the given algorithm. | ||
const hashAccordingGivenAlgorithm = crypto.createHash(core.getInput('algorithm')); | ||
|
||
// Calculating checksum for given file. | ||
const streamGivenFile = fs.createReadStream(core.getInput('file')); | ||
const calculatedChecksum = hashAccordingGivenAlgorithm.update(streamGivenFile).digest('hex'); | ||
|
||
const expectedChecksum = core.getInput('checksum'); | ||
|
||
console.log(`Calculated checksum: ${calculatedChecksum}`); | ||
console.log(`Expected checksum: ${expectedChecksum}`); | ||
|
||
if (calculatedChecksum == expectedChecksum) { | ||
core.setOutput("verify-result", "Checksums are equal"); | ||
} else { | ||
core.setOutput("verify-result", "Checksums are not equal"); | ||
core.setFailed(error.message); | ||
} | ||
} catch (error) { | ||
core.setFailed(error.message); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.