1
1
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/check-markdown-task.md
2
2
name : Check Markdown
3
3
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
5
9
on :
10
+ create :
6
11
push :
7
12
paths :
8
13
- " .github/workflows/check-markdown-task.ya?ml"
9
14
- " .markdown-link-check.json"
15
+ - " package.json"
16
+ - " package-lock.json"
10
17
- " Taskfile.ya?ml"
11
18
- " **/.markdownlint*"
12
19
- " **.mdx?"
17
24
paths :
18
25
- " .github/workflows/check-markdown-task.ya?ml"
19
26
- " .markdown-link-check.json"
27
+ - " package.json"
28
+ - " package-lock.json"
20
29
- " Taskfile.ya?ml"
21
30
- " **/.markdownlint*"
22
31
- " **.mdx?"
30
39
repository_dispatch :
31
40
32
41
jobs :
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
+
33
65
lint :
66
+ needs : run-determination
67
+ if : needs.run-determination.outputs.result == 'true'
34
68
runs-on : ubuntu-latest
35
69
36
70
steps :
37
71
- name : Checkout repository
38
72
uses : actions/checkout@v3
39
73
74
+ - name : Setup Node.js
75
+ uses : actions/setup-node@v3
76
+ with :
77
+ node-version : ${{ env.NODE_VERSION }}
78
+
40
79
- name : Initialize markdownlint-cli problem matcher
41
80
uses : xt0rted/markdownlint-problem-matcher@v1
42
81
@@ -50,12 +89,19 @@ jobs:
50
89
run : task markdown:lint
51
90
52
91
links :
92
+ needs : run-determination
93
+ if : needs.run-determination.outputs.result == 'true'
53
94
runs-on : ubuntu-latest
54
95
55
96
steps :
56
97
- name : Checkout repository
57
98
uses : actions/checkout@v3
58
99
100
+ - name : Setup Node.js
101
+ uses : actions/setup-node@v3
102
+ with :
103
+ node-version : ${{ env.NODE_VERSION }}
104
+
59
105
- name : Install Task
60
106
uses : arduino/setup-task@v1
61
107
with :
0 commit comments