From d0052f7dcd050d5a49198f60dcf5d9ba85c7b7c5 Mon Sep 17 00:00:00 2001 From: "Brian J. Murrell" Date: Tue, 24 Sep 2024 15:34:02 -0400 Subject: [PATCH] Initial commit (#1) Signed-off-by: Brian J. Murrell --- .github/workflows/test.yml | 38 +++++++++++++++++++++++++++++++++++ README.md | 2 +- action.yml | 41 ++++++++++++++++++++++++++++++-------- 3 files changed, 72 insertions(+), 9 deletions(-) create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..0232ec5 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,38 @@ +name: Test + +on: + push: + branches: + - master + pull_request: + +jobs: + test: + name: Test + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Test + id: test + uses: ./ + with: + commit-message: | + Use external action + + Run-GHA: true + Skip-PR-comments: true + Test-tag: always_passes,vm + + Required-githooks: true + + Signed-off-by: Brian J. Murrell + pragma: TEST_TAG + default: foobar + - name: Test value + run: | + set -eux + if [ '${{ steps.test.outputs.value }}' != 'always_passes,vm' ]; then + echo "Value is not 'always_passes,vm'" + exit 1 + fi diff --git a/README.md b/README.md index 49f45ea..4d4590e 100644 --- a/README.md +++ b/README.md @@ -1 +1 @@ -A GitHub Action to … +A GitHub Action to create a variable from a commit pragma diff --git a/action.yml b/action.yml index e0c038f..49226aa 100644 --- a/action.yml +++ b/action.yml @@ -1,12 +1,37 @@ -name: '…' -description: '…' -#inputs: -# : -# description: '…' -# required: true +name: 'Set Variable from Commit Pragma' +description: 'Set Variable from Commit Pragma' +inputs: + commit-message: + description: Dequoted commit message + required: true + pragma: + description: Pragma to make a variable from + required: true + default: + description: Default value if pragma is not found + required: false +outputs: + value: + description: The value of the pragma + value: ${{ steps.value.outputs.value }} + runs: using: "composite" steps: - - run: | - echo "…" + # checkout the common library + - name: Checkout code + uses: actions/checkout@v4 + with: + repository: daos-stack/actions-lib + ref: bmurrell/initial + path: actions-lib + - name: Create Variable + id: value shell: bash + run: | + set -eu + # using user input (the commit message) in an eval can be pretty dangerous + # but actions-lib/get_commit_pragmas does a good job of sanitizing it + eval $(echo '${{ inputs.commit-message }}' | actions-lib/get_commit_pragmas) + echo "value=${${{ inputs.pragma }}:-${{ inputs.default }}}" >> $GITHUB_OUTPUT + cat "$GITHUB_OUTPUT"