Skip to content

Commit 639d425

Browse files
authored
Merge PR #207 from webwarrior-ws/dynamic-uses-action
Add "dynamic uses" action to the repository root so it can be referenced and used in Github workflows. The action is originally from [1] and is a workaround to problem outlined in [2]. [1] https://github.com/jenseng/dynamic-uses [2] https://github.com/orgs/community/discussions/25246
2 parents e7f77c1 + e631af1 commit 639d425

File tree

2 files changed

+63
-8
lines changed

2 files changed

+63
-8
lines changed

.github/workflows/CI.yml

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ on:
1313
env:
1414
DOTNET_ROLL_FORWARD: Major
1515
TYPESCRIPT_VERSION: "5.8.3"
16+
CHECKOUT_ACTION_VERSION: "4"
1617

1718
jobs:
1819
build-fs:
@@ -21,7 +22,9 @@ jobs:
2122
container:
2223
image: "ubuntu:24.04"
2324
steps:
24-
- uses: actions/checkout@v4
25+
- uses: nblockchain/conventions@main
26+
with:
27+
uses: actions/checkout@v${{ env.CHECKOUT_ACTION_VERSION }}
2528
- name: Install required dependencies
2629
run: |
2730
apt update
@@ -50,7 +53,9 @@ jobs:
5053
container:
5154
image: "ubuntu:24.04"
5255
steps:
53-
- uses: actions/checkout@v4
56+
- uses: nblockchain/conventions@main
57+
with:
58+
uses: actions/checkout@v${{ env.CHECKOUT_ACTION_VERSION }}
5459
- name: Install required dependencies
5560
run: |
5661
apt update
@@ -76,7 +81,9 @@ jobs:
7681
container:
7782
image: "ubuntu:24.04"
7883
steps:
79-
- uses: actions/checkout@v4
84+
- uses: nblockchain/conventions@main
85+
with:
86+
uses: actions/checkout@v${{ env.CHECKOUT_ACTION_VERSION }}
8087
- name: Install required dependencies
8188
run: |
8289
apt update
@@ -114,7 +121,9 @@ jobs:
114121
container:
115122
image: "ubuntu:24.04"
116123
steps:
117-
- uses: actions/checkout@v4
124+
- uses: nblockchain/conventions@main
125+
with:
126+
uses: actions/checkout@v${{ env.CHECKOUT_ACTION_VERSION }}
118127
- name: Install required dependencies
119128
run: |
120129
apt update
@@ -167,11 +176,14 @@ jobs:
167176
sudo apt install --yes --no-install-recommends git
168177
# workaround for https://github.com/actions/runner/issues/2033
169178
git config --global --add safe.directory '*'
170-
- uses: actions/checkout@v4
179+
- uses: nblockchain/conventions@main
171180
with:
172-
submodules: recursive
173-
# needed because of commit-lint, see https://github.com/conventional-changelog/commitlint/issues/3376
174-
fetch-depth: 0
181+
uses: actions/checkout@v${{ env.CHECKOUT_ACTION_VERSION }}
182+
with: |
183+
{
184+
"submodules": "recursive",
185+
"fetch-depth": 0
186+
}
175187
- name: Print versions
176188
run: |
177189
git --version

action.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Dynamic Uses
2+
description: Dynamically resolve and use another GitHub action. Workaround for https://github.com/actions/runner/issues/895
3+
author: Jon Jensen
4+
inputs:
5+
uses:
6+
description: Action reference or path, e.g. `actions/setup-node@v3`
7+
required: true
8+
with:
9+
description: 'JSON-ified `inputs` for the action, e.g. `{"node-version": "18"}`'
10+
required: false
11+
default: "{}"
12+
outputs:
13+
outputs:
14+
description: 'JSON-ified `outputs` from the action, e.g. `{"node-version": "v18.12.0", "cache-hit": true}`'
15+
value: ${{ steps.run.outputs.outputs }}
16+
runs:
17+
using: composite
18+
steps:
19+
- name: Setup
20+
shell: bash
21+
run: |
22+
mkdir --parents ./.tmp-dynamic-uses &&
23+
cat <<'DYNAMIC_USES_EOF' >./.tmp-dynamic-uses/action.yml
24+
outputs:
25+
outputs:
26+
value: ${{ '$' }}{{ toJSON(steps.run.outputs) }}
27+
runs:
28+
using: composite
29+
steps:
30+
- run: rm --recursive --force ./.tmp-dynamic-uses
31+
shell: bash
32+
- name: Run
33+
id: run
34+
uses: ${{ inputs.uses }}
35+
with: ${{ inputs.with || '{}' }}
36+
DYNAMIC_USES_EOF
37+
- name: Run
38+
id: run
39+
uses: ./.tmp-dynamic-uses
40+
- name: Cleanup
41+
if: always() && steps.run.outcome != 'success'
42+
shell: bash
43+
run: rm --recursive --force ./.tmp-dynamic-uses

0 commit comments

Comments
 (0)