From 2f5491750f58860ef34c9eb1aca6d997eaf6eb2a 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..19e9bb4 --- /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..9a745ef 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"