File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed
Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change 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
57runs :
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
You can’t perform that action at this time.
0 commit comments