From 12cb9448cd89ee81496504209af42ebc105ad4ab Mon Sep 17 00:00:00 2001 From: Kevin Heis Date: Wed, 31 May 2023 12:48:45 -0700 Subject: [PATCH] Use shared check-file action --- .github/script/check-file.sh | 42 ------------------ .../workflows/1-configure-label-based-job.yml | 8 ++-- .../workflows/2-setup-azure-environment.yml | 44 ++++++++++++++++--- 3 files changed, 41 insertions(+), 53 deletions(-) delete mode 100755 .github/script/check-file.sh diff --git a/.github/script/check-file.sh b/.github/script/check-file.sh deleted file mode 100755 index 85236a5..0000000 --- a/.github/script/check-file.sh +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env bash -# Make sure this file is executable -# chmod a+x .github/script/check-file.sh - -# Make sure to escape your backslashes => \\ <= in YAML -# So that its still a single \ in bash - -# Check if pattern match found in file -grep_pattern() { - echo - echo "Check that $1 includes $2" - if grep --extended-regexp "$2" -- $1 - then - echo "Found $2 in $1" - else - echo "Missing $2 in $1" - echo "----------------" - echo "$(cat $1)" - exit 204 # We're sending a weird code so it looks different from other "failures" - fi -} - -# Run grep check for each term in list -search_list() { - for pattern in "$@" - do - grep_pattern $FILE $pattern - done -} - -# Handle single search term -if [ -n "${SEARCH+set}" ] && [ -n "${FILE+set}" ]; then - grep_pattern $FILE $SEARCH - -# Handle multiple search terms, space delimited -elif [ -n "${SEARCH_LIST+set}" ] && [ -n "${FILE+set}" ]; then - search_list $SEARCH_LIST - -# Missing FILE or search term(s) -else - echo "FILE and (SEARCH | SEARCH_LIST) required" -fi diff --git a/.github/workflows/1-configure-label-based-job.yml b/.github/workflows/1-configure-label-based-job.yml index 912c14a..a02c3e3 100644 --- a/.github/workflows/1-configure-label-based-job.yml +++ b/.github/workflows/1-configure-label-based-job.yml @@ -57,10 +57,10 @@ jobs: # Verify the learner added the specific label triggers. - name: Verify workflow - run: ./.github/script/check-file.sh - env: - FILE: .github/workflows/deploy-staging.yml - SEARCH: "github.event.pull_request.labels\\.\\*.name.*stage" + uses: skills/action-check-file@v1 + with: + file: .github/workflows/deploy-staging.yml + search: "github.event.pull_request.labels\\.\\*.name.*stage" # In README.md, switch step 1 for step 2. - name: Update to step 2 diff --git a/.github/workflows/2-setup-azure-environment.yml b/.github/workflows/2-setup-azure-environment.yml index b78f962..d4adfb3 100644 --- a/.github/workflows/2-setup-azure-environment.yml +++ b/.github/workflows/2-setup-azure-environment.yml @@ -57,17 +57,47 @@ jobs: # Verify the learner configured Build-Docker-Image job. - name: Verify Build-Docker-Image job - run: .github/script/check-file.sh - env: - FILE: .github/workflows/deploy-staging.yml - SEARCH_LIST: "Build-Docker-Image actions/download-artifact docker/login-action docker/build-push-action" + uses: skills/action-check-file@v1 + with: + file: .github/workflows/deploy-staging.yml + search: "Build-Docker-Image" + + - name: Verify Build-Docker-Image job + uses: skills/action-check-file@v1 + with: + file: .github/workflows/deploy-staging.yml + search: "actions/download-artifact" + + - name: Verify Build-Docker-Image job + uses: skills/action-check-file@v1 + with: + file: .github/workflows/deploy-staging.yml + search: "docker/login-action" + + - name: Verify Build-Docker-Image job + uses: skills/action-check-file@v1 + with: + file: .github/workflows/deploy-staging.yml + search: "docker/build-push-action" # Verify the learner configured the Deploy-to-Azure job. - name: Verify Deploy-to-Azure job - run: .github/script/check-file.sh + uses: skills/action-check-file@v1 + env: + file: .github/workflows/deploy-staging.yml + search: "Deploy-to-Azure" + + - name: Verify Deploy-to-Azure job + uses: skills/action-check-file@v1 + env: + file: .github/workflows/deploy-staging.yml + search: "azure/login" + + - name: Verify Deploy-to-Azure job + uses: skills/action-check-file@v1 env: - FILE: .github/workflows/deploy-staging.yml - SEARCH_LIST: "Deploy-to-Azure azure/login azure/webapps-deploy" + file: .github/workflows/deploy-staging.yml + search: "azure/webapps-deploy" # Merge the pull open pull request. - name: Merge Pull Request