diff --git a/.github/workflows/check-sync.yml b/.github/workflows/check-sync.yml index 074c1dab..c06a3854 100644 --- a/.github/workflows/check-sync.yml +++ b/.github/workflows/check-sync.yml @@ -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 @@ -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 diff --git a/Taskfile.yml b/Taskfile.yml index 4474bf9b..5c8bfd99 100644 --- a/Taskfile.yml +++ b/Taskfile.yml @@ -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: diff --git a/etc/sync.sh b/etc/sync.sh deleted file mode 100755 index 70d6fc6e..00000000 --- a/etc/sync.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/bash -# Sync the repository's intentionally duplicated files. - -readonly REPOSITORY_ROOT_PATH="$(git rev-parse --show-toplevel)" -readonly WORKFLOW_TEMPLATE_ASSETS_PATH="${REPOSITORY_ROOT_PATH}/workflow-templates/assets" -readonly WORKFLOW_TEMPLATES_PATH="${REPOSITORY_ROOT_PATH}/workflow-templates" -readonly WORKFLOWS_PATH="${REPOSITORY_ROOT_PATH}/.github/workflows" -readonly WORKFLOW_TEMPLATE_COPIES_PATH="${REPOSITORY_ROOT_PATH}/workflow-templates/dependabot/workflow-template-copies/.github/workflows" - -# 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 -and \( -name '*.yml' -or -name '*.yaml' \) -exec cp '{}' "$WORKFLOW_TEMPLATE_COPIES_PATH" \;