generated from cloudposse-github-actions/composite-template
-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
## what * Fix special chars issue
- Loading branch information
Showing
489 changed files
with
36,766 additions
and
65 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,115 @@ | ||
name: Test special chars | ||
on: | ||
# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered | ||
# # | ||
# # Added pull_request to register workflow from the PR. | ||
# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo | ||
# pull_request: {} | ||
workflow_dispatch: | ||
inputs: | ||
paths: | ||
description: 'A multiline yaml string of key/value pairs for each Name and Path to include in the comment' | ||
required: false | ||
default: | | ||
Application: application | ||
Dashboard: /dashboard | ||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
target: ["one", "two"] | ||
steps: | ||
- name: Setup | ||
run: echo "Do setup" | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- uses: ./ | ||
id: writer | ||
with: | ||
matrix-step-name: ${{ github.job }} | ||
matrix-key: ${{ matrix.target }} | ||
outputs: |- | ||
result2: ${{ matrix.target }} | ||
test: "comment: URL for deploy: https://frontend-docs-259.website.dev" | ||
test2: "comment: URL for deploy: ' https://frontend-docs-259.website.dev" | ||
test3: ${{ toJson(inputs.paths) }} | ||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: ${{ matrix.target }} | ||
actual: ${{ fromJson(steps.writer.outputs.result).result2 }} | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: ${{ matrix.target }} | ||
actual: ${{ steps.writer.outputs.result2 }} | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: "comment: URL for deploy: https://frontend-docs-259.website.dev" | ||
actual: ${{ fromJson(steps.writer.outputs.result).test }} | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: "comment: URL for deploy: https://frontend-docs-259.website.dev" | ||
actual: ${{ steps.writer.outputs.test }} | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: "comment: URL for deploy: ' https://frontend-docs-259.website.dev" | ||
actual: ${{ fromJson(steps.writer.outputs.result).test2 }} | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: "comment: URL for deploy: ' https://frontend-docs-259.website.dev" | ||
actual: ${{ steps.writer.outputs.test2 }} | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: | | ||
Application: application | ||
Dashboard: /dashboard | ||
actual: ${{ fromJson(steps.writer.outputs.result).test3 }} | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: | | ||
Application: application | ||
Dashboard: /dashboard | ||
actual: ${{ steps.writer.outputs.test3 }} | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
continue-on-error: true | ||
needs: [setup] | ||
steps: | ||
- uses: actions/download-artifact@v3 | ||
|
||
- id: current | ||
run: |- | ||
echo "result=$(ls | wc -l)" >> $GITHUB_OUTPUT | ||
outputs: | ||
result: "${{ steps.current.outputs.result }}" | ||
|
||
assert: | ||
runs-on: ubuntu-latest | ||
needs: [test] | ||
steps: | ||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: '2' | ||
actual: "${{ needs.test.outputs.result }}" | ||
|
||
|
||
teardown: | ||
runs-on: ubuntu-latest | ||
needs: [assert] | ||
if: ${{ always() }} | ||
steps: | ||
- name: Tear down | ||
run: echo "Do Tear down" |
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,66 @@ | ||
name: Test validation | ||
on: | ||
# # Uncomment when test added first time to register workflow and comment it back after workflow would be registered | ||
# # | ||
# # Added pull_request to register workflow from the PR. | ||
# # Read more https://stackoverflow.com/questions/63362126/github-actions-how-to-run-a-workflow-created-on-a-non-master-branch-from-the-wo | ||
# pull_request: {} | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
setup: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Setup | ||
run: echo "Do setup" | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
target: ["one", "two"] | ||
continue-on-error: true | ||
needs: [setup] | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
|
||
- uses: ./ | ||
id: current | ||
with: | ||
matrix-step-name: ${{ github.job }} | ||
matrix-key: ${{ matrix.target }} | ||
outputs: |- | ||
result: ${{ matrix.target }} | ||
test: comment: URL for deploy: https://frontend-docs-259.website.dev | ||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: ${{ matrix.target }} | ||
actual: ${{ fromJson(steps.writer.outputs.result).result }} | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: "comment: URL for deploy: https://frontend-docs-259.website.dev" | ||
actual: ${{ fromJson(steps.writer.outputs.result).test }} | ||
|
||
outputs: | ||
result: "${{ steps.current.outcome }}" | ||
|
||
assert: | ||
runs-on: ubuntu-latest | ||
needs: [test] | ||
steps: | ||
- uses: nick-fields/assert-action@v1 | ||
with: | ||
expected: 'failure' | ||
actual: "${{ needs.test.outputs.result }}" | ||
|
||
|
||
teardown: | ||
runs-on: ubuntu-latest | ||
needs: [assert] | ||
if: ${{ always() }} | ||
steps: | ||
- name: Tear down | ||
run: echo "Do Tear down" |
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 |
---|---|---|
|
@@ -16,69 +16,7 @@ inputs: | |
description: "YAML structured map of outputs" | ||
outputs: | ||
result: | ||
description: "Outputs result" | ||
value: "${{ steps.proxy.outputs.result }}" | ||
description: "Outputs result (Deprecated!!!)" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: nick-fields/assert-action@v1 | ||
if: ${{ inputs.matrix-key != '' }} | ||
with: | ||
expected: '' | ||
actual: "${{ inputs.matrix-step-name }}" | ||
comparison: notEqual | ||
|
||
- uses: nick-fields/assert-action@v1 | ||
if: ${{ inputs.matrix-step-name != '' }} | ||
with: | ||
expected: '' | ||
actual: "${{ inputs.matrix-key }}" | ||
comparison: notEqual | ||
|
||
- name: 'Install jq 1.6' | ||
uses: dcarbone/[email protected] | ||
with: | ||
version: 1.6 | ||
force: 'true' | ||
|
||
- name: 'Setup yq' | ||
uses: dcarbone/[email protected] | ||
with: | ||
version: v4.28.1 | ||
download-compressed: true | ||
force: true | ||
|
||
- shell: bash | ||
id: proxy | ||
run: |- | ||
JSON=$(echo "${{ inputs.outputs }}" | yq '. + {}' -o json | jq . -c -M -e) | ||
echo "result=${JSON}" >> $GITHUB_OUTPUT | ||
- uses: cloudposse/[email protected] | ||
id: mask | ||
with: | ||
query: .${{ inputs.matrix-key == '' }} | ||
config: |- | ||
true: | ||
mask: ". + {}" | ||
false: | ||
mask: "{\"${{ inputs.matrix-key}}\": . + {}}" | ||
- shell: bash | ||
id: write | ||
run: |- | ||
JSON=$(echo "${{ inputs.outputs }}" | yq '${{ steps.mask.outputs.mask }}' -o json | jq . -c -M -e) | ||
echo "result=${JSON}" >> $GITHUB_OUTPUT | ||
- shell: bash | ||
if: ${{ inputs.outputs != '' && inputs.matrix-step-name != '' }} | ||
run: | | ||
echo '${{ steps.write.outputs.result }}' > ${{ inputs.matrix-step-name }} | ||
id: matrix | ||
|
||
- uses: actions/upload-artifact@v3 | ||
if: ${{ inputs.outputs != '' && inputs.matrix-step-name != '' }} | ||
with: | ||
name: ${{ hashFiles( inputs.matrix-step-name ) || 'none' }} | ||
path: ${{ inputs.matrix-step-name }} | ||
if-no-files-found: warn | ||
using: "node16" | ||
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,89 @@ | ||
const core = require('@actions/core'); | ||
const yaml = require('yaml') | ||
const artifact = require('@actions/artifact'); | ||
const crypto = require('crypto'); | ||
const fs = require('fs'); | ||
|
||
try { | ||
const step_name = core.getInput('matrix-step-name'); | ||
const matrix_key = core.getInput('matrix-key'); | ||
const outputs = core.getInput('outputs'); | ||
|
||
core.debug("step_name:") | ||
core.debug(step_name) | ||
|
||
core.debug("matrix_key:") | ||
core.debug(matrix_key) | ||
|
||
core.debug("outputs:") | ||
core.debug(outputs) | ||
|
||
function isEmptyInput(value) { | ||
return value === null || value.trim() === ""; | ||
} | ||
|
||
if (isEmptyInput(step_name) && !isEmptyInput(matrix_key)) { | ||
core.setFailed("`matrix-step-name` can not be empty when `matrix-key` specified"); | ||
return | ||
} | ||
|
||
if (!isEmptyInput(step_name) && isEmptyInput(matrix_key)) { | ||
core.setFailed("`matrix-key` can not be empty when `matrix-step-name` specified"); | ||
return | ||
} | ||
|
||
if (!isEmptyInput(outputs)) { | ||
try { | ||
yaml.parse(outputs) | ||
} | ||
catch (error) { | ||
message = `Outputs should be valid YAML | ||
--------------------- | ||
${outputs} | ||
--------------------- | ||
${error}`; | ||
core.setFailed(message); | ||
return | ||
} | ||
} | ||
|
||
const outputs_struct = !isEmptyInput(outputs) ? yaml.parse(outputs) : {} | ||
|
||
Object.keys(outputs_struct).forEach(function(key, index) { | ||
core.setOutput(key, outputs_struct[key]) | ||
}); | ||
|
||
core.debug("outputs_struct:") | ||
core.debug(outputs_struct) | ||
|
||
core.debug("JSON.stringify(outputs_struct):") | ||
core.debug(JSON.stringify(outputs_struct)) | ||
|
||
core.setOutput('result', JSON.stringify(outputs_struct)) | ||
|
||
if (!isEmptyInput(outputs)) { | ||
const artifact_content = isEmptyInput(matrix_key) ? outputs_struct : { matrix_key: outputs_struct } | ||
|
||
fs.writeFileSync("./" + step_name, JSON.stringify(artifact_content)); | ||
const fileBuffer = fs.readFileSync("./" + step_name); | ||
const hashSum = crypto.createHash('sha256'); | ||
hashSum.update(fileBuffer); | ||
|
||
const hex = hashSum.digest('hex'); | ||
|
||
const artifactClient = artifact.create() | ||
const artifactName = hex; | ||
const files = [ | ||
"./" + step_name, | ||
] | ||
|
||
const rootDirectory = '.' // Also possible to use __dirname | ||
const options = { | ||
continueOnError: false | ||
} | ||
|
||
const uploadResponse = artifactClient.uploadArtifact(artifactName, files, rootDirectory, options) | ||
} | ||
} 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.