Skip to content

Commit

Permalink
gh-actions/using/steps: Add action (#909)
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Northey <ryan@synca.io>
  • Loading branch information
phlax authored Oct 28, 2023
1 parent 1aecd9d commit 19f2ebd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
25 changes: 25 additions & 0 deletions gh-actions/using/steps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

inputs:
steps:
type: string
required: true
name:
default:

runs:
using: composite
steps:
- id: create-steps
shell: bash
# This allows latebinding using `%{{ }}`
# For example, to use output from a previous step you can use
# %{{ steps.stepname.outputs }}
run: ${{ github.action_path }}/create-steps.sh
env:
STEPS: ${{ inputs.steps }}
- name: Run (${{ inputs.name || '.tmp.action' }})
uses: ./.tmp.action
- name: Cleanup (.tmp.action)
if: always()
shell: bash
run: rm -rf .tmp.action
6 changes: 6 additions & 0 deletions gh-actions/using/steps/create-steps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash -e

mkdir -p .tmp.action
output=$(printf "%s\n" "${STEPS}" \
| sed 's/\([^\\]\)%{{ /\1${{ /g; s/^/ /')
printf "runs:\n using: composite\n steps:\n%s\n" "${output}" > .tmp.action/action.yml

0 comments on commit 19f2ebd

Please sign in to comment.