-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathaction.yml
More file actions
79 lines (71 loc) · 2.88 KB
/
Copy pathaction.yml
File metadata and controls
79 lines (71 loc) · 2.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# DEPRECATED! Use asset-lint instead. It lints Markdown files with markdownlint and textlint too.
name: Markdown Linting
description: >
Lints markdown files by wrapping the markdownlint-cli2 action
(https://github.com/DavidAnson/markdownlint-cli2-action).
inputs:
config:
description: Path to a file to use for the base configuration object (defaults to "lombiq.markdownlint.json").
default: lombiq.markdownlint.json
required: false
fix:
description: Whether to fix issues automatically for the rules that support it (any truthy value enables).
default: ''
required: false
globs:
description: Glob expression(s) of files to lint (newline-delimited).
default: >
**/*.{md,markdown}
!node_modules
!License.md
required: false
separator:
description: String to use as a separator for the "globs" input (defaults to newline).
default: \n
required: false
runs:
using: composite
steps:
- name: Setup
shell: pwsh
run: |
(Resolve-Path '${{ github.action_path }}/../../../Scripts').Path >> $Env:GITHUB_PATH
# Copy the default configuration file so it's accessible without path complications.
if (-not (Test-Path lombiq.markdownlint.json))
{
Copy-Item '${{ github.action_path }}/lombiq.markdownlint.json' .
}
- name: Markdown Linting
uses: DavidAnson/markdownlint-cli2-action@21c1be1b93ad9ed58fa840aacc3f279cde2a72ff # v24
with:
config: ${{ inputs.config }}
fix: ${{ inputs.fix }}
globs: ${{ inputs.globs }}
separator: ${{ inputs.separator }}
- name: Copy files updated by markdown-lint automatic fixes
if: inputs.fix == 'true'
id: markdown-lint-fix-files
shell: pwsh
run: |
$artifactFolder = [System.Guid]::NewGuid()
$files = git diff --name-only '*.md' '*.markdown'
$files | ForEach-Object {
$destination = "$artifactFolder/$PSItem"
New-Item -ItemType File -Path $destination -Force
Copy-Item -Path $PSItem -Destination $destination -Force
}
Set-GitHubOutput 'has-fixes' ($files.Length -gt 0).ToString().ToLower()
Set-GitHubOutput 'artifact-path' $artifactFolder
- name: Upload files fixed by markdown-lint
uses: Lombiq/GitHub-Actions/.github/actions/upload-artifact@issue/OSOE-1308
if: inputs.fix == 'true' && steps.markdown-lint-fix-files.outputs.has-fixes == 'true'
with:
name: markdown-lint-fixed-files
path: ${{ steps.markdown-lint-fix-files.outputs.artifact-path }}
retention-days: 1
- name: Fail workflow if markdown-lint fixes were made
if: inputs.fix == 'true' && steps.markdown-lint-fix-files.outputs.has-fixes == 'true'
shell: pwsh
run: |
Write-Output '::error::Some files were modified by markdown-lint and are available to download as artifacts.'
exit 1