Skip to content

Commit 56e3e2e

Browse files
committed
Upload corrected files to workflow artifact if ToC is outdated
Some assets contain a table of contents to facilitate the navigation of their content. The table of contents must be kept in sync with the content. The continuous integration system uses the excellent markdown-toc tool to detect outdated table of contents. In order to support checking any number of files at arbitrary paths in the repository, using a specified `--maxdepth` flag value for each, a job matrix is used in the "Check ToC" GitHub Actions workflow. The user may also run the `markdown:toc` locally to update the table of contents, but because the project-specific configuration is implemented in the workflow instead of the taskfile they must specify the file's path and `--maxdepth` flag value via task variables in the invocation. Contributors may find it challenging to update the table of contents. In order to facilitate the update following detection of an out of sync state by the continuous integration system, the corrected file is uploaded to a workflow artifact. The contributor can download the workflow artifact and replace the out of sync file with the corrected version.
1 parent 3d8ebb6 commit 56e3e2e

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

.github/workflows/check-toc-task.yml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,9 @@ jobs:
5656
if: needs.run-determination.outputs.result == 'true'
5757
runs-on: ubuntu-latest
5858

59+
env:
60+
ARTIFACT_NAME: corrected-files
61+
5962
strategy:
6063
fail-fast: false
6164

@@ -86,4 +89,20 @@ jobs:
8689
MAX_DEPTH=${{ matrix.file.maxdepth }}
8790
8891
- name: Check ToC
92+
id: check-toc
8993
run: git diff --color --exit-code
94+
95+
- name: Upload corrected file to workflow artifact
96+
if: failure() && steps.check-toc.outcome == 'failure'
97+
uses: actions/upload-artifact@v3
98+
with:
99+
if-no-files-found: error
100+
name: ${{ env.ARTIFACT_NAME }}
101+
# Globstar prefix is to preserve folder structure in artifact.
102+
# https://github.com/actions/upload-artifact/tree/v3.1.2#:~:text=path%20hierarchy%20will%20be%20preserved
103+
path: "**/${{ matrix.file.name }}"
104+
105+
- name: Add artifact availability notice
106+
if: failure() && steps.check-toc.outcome == 'failure'
107+
run: |
108+
echo "::notice file=${{ matrix.file.name }}::Corrected file was saved to the ${{ env.ARTIFACT_NAME }} workflow artifact"

Taskfile.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ tasks:
2020
- task: general:correct-spelling
2121
- task: general:format-prettier
2222
- task: markdown:fix
23-
- task: markdown:toc
2423

2524
# Source: https://github.com/arduino/tooling-project-assets/blob/main/workflow-templates/assets/check-workflows-task/Taskfile.yml
2625
ci:validate:

0 commit comments

Comments
 (0)