Skip to content

Commit c8b9527

Browse files
committed
Use a task for syncing file duplicates
This repository contains intentionally duplicated template workflow copies under `workflow-templates/dependabot/workflow-template-copies`. These are used for the Dependabot checks for outdated action versions. It's essential that these be kept in sync with the source files, and this is enforced by a CI workflow. So the sync process will need to be run by the developer whenever modifying the template workflows. A Bash script was previously provided to facilitate syncing, and used by the CI system. However, the Tooling Team standard is to use Task for development processes that are regularly run locally. So a Task-based approach is most appropriate.
1 parent 1426752 commit c8b9527

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

.github/workflows/check-sync.yml

+14-4
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# - Assets for the workflow templates used in this repository.
55
#
66
# This workflow checks that the copies are in sync.
7-
# If the workflow fails, run workflow-templates/etc/sync.sh and commit.
7+
# If the workflow fails, run `task dependabot:sync` and commit.
88

99
name: Check File Duplicates Sync
1010

@@ -16,16 +16,26 @@ jobs:
1616
check-sync:
1717
runs-on: ubuntu-latest
1818

19+
env:
20+
SYNC_COMMAND: task dependabot:sync
21+
1922
steps:
2023
- name: Checkout repository
2124
uses: actions/checkout@v2
2225

26+
- name: Install Task
27+
uses: arduino/setup-task@v1
28+
with:
29+
repo-token: ${{ secrets.GITHUB_TOKEN }}
30+
version: 3.x
31+
32+
- name: Sync files
33+
run: ${{ env.SYNC_COMMAND }} --silent
34+
2335
- name: Check file duplicates sync
2436
run: |
25-
SYNC_SCRIPT_PATH="etc/sync.sh"
26-
"${{ github.workspace }}/$SYNC_SCRIPT_PATH"
2737
git add .
2838
if ! git diff --color --exit-code HEAD; then
29-
echo "::error::File duplicates are out of sync. Please run $SYNC_SCRIPT_PATH"
39+
echo "::error::File duplicates are out of sync. Please run \"${{ env.SYNC_COMMAND }}\""
3040
exit 1
3141
fi

Taskfile.yml

+21
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,32 @@
11
version: "3"
22

33
tasks:
4+
fix:
5+
desc: Make automated corrections to the project's files
6+
deps:
7+
- task: dependabot:sync
8+
49
check:
510
desc: Check for problems with the project
611
deps:
712
- task: config:validate
813

14+
dependabot:sync:
15+
desc: Sync workflow duplicates for dependabot checks
16+
vars:
17+
WORKFLOW_TEMPLATES_PATH: "./workflow-templates"
18+
WORKFLOW_TEMPLATE_COPIES_PATH: "./workflow-templates/dependabot/workflow-template-copies/.github/workflows"
19+
cmds:
20+
# Sync workflow templates with the copies in the folder where Dependabot can check them for updates.
21+
- mkdir --parents "{{.WORKFLOW_TEMPLATE_COPIES_PATH}}"
22+
- rm --force "{{.WORKFLOW_TEMPLATE_COPIES_PATH}}"/*
23+
- |
24+
find "{{.WORKFLOW_TEMPLATES_PATH}}" \
25+
-maxdepth 1 \
26+
-type f \
27+
-regex '.*\.ya?ml' \
28+
-exec cp '{}' "{{.WORKFLOW_TEMPLATE_COPIES_PATH}}" \;
29+
930
config:validate:
1031
desc: Validate configuration files against their JSON schema
1132
vars:

etc/sync.sh

-13
This file was deleted.

0 commit comments

Comments
 (0)