Skip to content

Commit 3ce4dc3

Browse files
committed
Add config/action.yaml to process the CI workflow configuration.
A github action to process the configuration for the CI workflow. Outputs: - `jobs`: The list of CI jobs to run (test, build, publish, release). - `os`: The list of operating systems on which to run the tests. - `python-version`: The list of python versions on which to run the tests. Invoke with `uses: glenn20/python-ci/config@v2`
1 parent 1c52b41 commit 3ce4dc3

File tree

1 file changed

+42
-0
lines changed

1 file changed

+42
-0
lines changed

config/action.yaml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: Setup CI workflow configuraqtion
2+
description: |-
3+
A github action to process the configuration for the CI workflow.
4+
Outputs:
5+
- `jobs`: The list of CI jobs to run (test, build, publish, release).
6+
- `os`: The list of operating systems on which to run the tests.
7+
- `python-version`: The list of python versions on which to run the tests.
8+
Invoke with `uses: glenn20/python-ci/config@v2`
9+
author: glenn20
10+
11+
inputs:
12+
config:
13+
description: 'Configuration for the CI workflow.'
14+
required: true
15+
16+
outputs:
17+
jobs:
18+
description: 'The list of CI jobs to run (test, build, publish, release).'
19+
value: ${{ steps.config.outputs.jobs }}
20+
os:
21+
description: 'The list of operating systems on which to run the tests.'
22+
value: ${{ steps.config.outputs.os }}
23+
python-version:
24+
description: 'The list of python versions on which to run the tests.'
25+
value: ${{ steps.config.outputs.python-version }}
26+
27+
runs:
28+
using: 'composite'
29+
steps:
30+
- name: Select the workflow configuration
31+
id: config
32+
run: | # Find the matching environment variable based on the event trigger
33+
tag="on-${{ github.event_name }}-${{ github.ref_type }}-${{ github.ref_name }}"
34+
for key in $(echo '${{ inputs.config }}' | jq -r 'keys_unsorted[]'); do
35+
if [[ "$tag" == $key ]]; then
36+
# Write value of the matching environment variable to $GITHUB_OUTPUT
37+
echo '${{ inputs.config }}' | jq -r ".[\"$key\"]" >> $GITHUB_OUTPUT
38+
exit 0 # Stop after the first match
39+
fi
40+
done
41+
echo "No matching environment variable found for '$tag'."
42+
shell: bash

0 commit comments

Comments
 (0)