11# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-markdown-task.md
22name : Check Markdown
33
4- # See: https://docs.github.com/en/actions/reference/events-that-trigger-workflows
4+ env :
5+ # See: https://github.com/actions/setup-node/#readme
6+ NODE_VERSION : 16.x
7+
8+ # See: https://docs.github.com/actions/using-workflows/events-that-trigger-workflows
59on :
10+ create :
611 push :
712 paths :
813 - " .github/workflows/check-markdown-task.ya?ml"
914 - " .markdown-link-check.json"
15+ - " package.json"
16+ - " package-lock.json"
1017 - " Taskfile.ya?ml"
1118 - " **/.markdownlint*"
1219 - " **.mdx?"
1724 paths :
1825 - " .github/workflows/check-markdown-task.ya?ml"
1926 - " .markdown-link-check.json"
27+ - " package.json"
28+ - " package-lock.json"
2029 - " Taskfile.ya?ml"
2130 - " **/.markdownlint*"
2231 - " **.mdx?"
3039 repository_dispatch :
3140
3241jobs :
42+ run-determination :
43+ runs-on : ubuntu-latest
44+ outputs :
45+ result : ${{ steps.determination.outputs.result }}
46+ steps :
47+ - name : Determine if the rest of the workflow should run
48+ id : determination
49+ run : |
50+ RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x"
51+ # The `create` event trigger doesn't support `branches` filters, so it's necessary to use Bash instead.
52+ if [[
53+ "${{ github.event_name }}" != "create" ||
54+ "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX
55+ ]]; then
56+ # Run the other jobs.
57+ RESULT="true"
58+ else
59+ # There is no need to run the other jobs.
60+ RESULT="false"
61+ fi
62+
63+ echo "::set-output name=result::$RESULT"
64+
3365 lint :
66+ needs : run-determination
67+ if : needs.run-determination.outputs.result == 'true'
3468 runs-on : ubuntu-latest
3569
3670 steps :
3771 - name : Checkout repository
3872 uses : actions/checkout@v3
3973
74+ - name : Setup Node.js
75+ uses : actions/setup-node@v3
76+ with :
77+ node-version : ${{ env.NODE_VERSION }}
78+
4079 - name : Initialize markdownlint-cli problem matcher
4180 uses : xt0rted/markdownlint-problem-matcher@v1
4281
@@ -50,12 +89,19 @@ jobs:
5089 run : task markdown:lint
5190
5291 links :
92+ needs : run-determination
93+ if : needs.run-determination.outputs.result == 'true'
5394 runs-on : ubuntu-latest
5495
5596 steps :
5697 - name : Checkout repository
5798 uses : actions/checkout@v3
5899
100+ - name : Setup Node.js
101+ uses : actions/setup-node@v3
102+ with :
103+ node-version : ${{ env.NODE_VERSION }}
104+
59105 - name : Install Task
60106 uses : arduino/setup-task@v1
61107 with :
0 commit comments