Skip to content

Commit d04c1d8

Browse files
committed
test
1 parent 5b5b8d3 commit d04c1d8

File tree

1 file changed

+14
-12
lines changed

1 file changed

+14
-12
lines changed

.github/workflows/action.yaml

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1-
name: action
2-
3-
on: [ push ]
4-
1+
inputs:
2+
if:
3+
description: Your condition
4+
default: true
5+
step:
6+
description: Your step to run if the condition is met
57
runs:
68
using: composite
79
steps:
8-
- uses: actions/github-script@v5
10+
- uses: actions/github-script@v4
911
with:
1012
github-token: none
1113
script: |
@@ -14,11 +16,11 @@ runs:
1416
fs.mkdirSync('./.github/conditional/tmp', {recursive: true});
1517
} catch {
1618
}
17-
fs.writeFileSync('./.github/conditional/tmp/action.yml', 'name: GitHub Actions Demo
18-
on: [push]
19-
jobs:
20-
Explore-GitHub-Actions:
21-
runs-on: ubuntu-latest
22-
steps:
23-
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."');
19+
if(${{fromJSON(inputs.if)}}) {
20+
fs.writeFileSync('./.github/conditional/tmp/action.yml', 'runs:\n using: composite\n steps:\n - ' + process.env['STEP'].replace(/\n/g, '\n '));
21+
} else {
22+
fs.writeFileSync('./.github/conditional/tmp/action.yml', 'runs: {using: composite, steps: []}');
23+
}
24+
env:
25+
STEP: ${{inputs.step}}
2426
- uses: ./.github/conditional/tmp

0 commit comments

Comments
 (0)