Skip to content

Use a task for syncing file duplicates #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions .github/workflows/check-sync.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# - Assets for the workflow templates used in this repository.
#
# This workflow checks that the copies are in sync.
# If the workflow fails, run workflow-templates/etc/sync.sh and commit.
# If the workflow fails, run `task dependabot:sync` and commit.

name: Check File Duplicates Sync

Expand All @@ -16,16 +16,26 @@ jobs:
check-sync:
runs-on: ubuntu-latest

env:
SYNC_COMMAND: task dependabot:sync

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Install Task
uses: arduino/setup-task@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
version: 3.x

- name: Sync files
run: ${{ env.SYNC_COMMAND }} --silent

- name: Check file duplicates sync
run: |
SYNC_SCRIPT_PATH="etc/sync.sh"
"${{ github.workspace }}/$SYNC_SCRIPT_PATH"
git add .
if ! git diff --color --exit-code HEAD; then
echo "::error::File duplicates are out of sync. Please run $SYNC_SCRIPT_PATH"
echo "::error::File duplicates are out of sync. Please run \"${{ env.SYNC_COMMAND }}\""
exit 1
fi
21 changes: 21 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
version: "3"

tasks:
fix:
desc: Make automated corrections to the project's files
deps:
- task: dependabot:sync

check:
desc: Check for problems with the project
deps:
- task: config:validate

dependabot:sync:
desc: Sync workflow duplicates for dependabot checks
vars:
WORKFLOW_TEMPLATES_PATH: "./workflow-templates"
WORKFLOW_TEMPLATE_COPIES_PATH: "./workflow-templates/dependabot/workflow-template-copies/.github/workflows"
cmds:
# Sync workflow templates with the copies in the folder where Dependabot can check them for updates.
- mkdir --parents "{{.WORKFLOW_TEMPLATE_COPIES_PATH}}"
- rm --force "{{.WORKFLOW_TEMPLATE_COPIES_PATH}}"/*
- |
find "{{.WORKFLOW_TEMPLATES_PATH}}" \
-maxdepth 1 \
-type f \
-regex '.*\.ya?ml' \
-exec cp '{}' "{{.WORKFLOW_TEMPLATE_COPIES_PATH}}" \;

config:validate:
desc: Validate configuration files against their JSON schema
vars:
Expand Down
13 changes: 0 additions & 13 deletions etc/sync.sh

This file was deleted.