Skip to content

Commit

Permalink
Initial commit (#1)
Browse files Browse the repository at this point in the history
Signed-off-by: Brian J. Murrell <[email protected]>
  • Loading branch information
brianjmurrell authored Sep 24, 2024
1 parent fc1afbc commit 2f54917
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 9 deletions.
38 changes: 38 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
A GitHub Action to
A GitHub Action to create a variable from a commit pragma
41 changes: 33 additions & 8 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,37 @@
name: ''
description: ''
#inputs:
# <name>:
# 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"

0 comments on commit 2f54917

Please sign in to comment.