From 7eff8dee81de4e2149256c8cd33ea577c6685b6a Mon Sep 17 00:00:00 2001 From: Seth Cottle Date: Mon, 17 Mar 2025 18:38:43 -0400 Subject: [PATCH 1/4] manual trigger --- .github/contrast-check.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/contrast-check.yml b/.github/contrast-check.yml index c533c87b..58e1f40d 100644 --- a/.github/contrast-check.yml +++ b/.github/contrast-check.yml @@ -3,6 +3,7 @@ on: pull_request: paths: - 'css/brands.css' + workflow_dispatch: jobs: contrast-check: From 3e71e529e2f62597fbacd653d47f97f256aec2f8 Mon Sep 17 00:00:00 2001 From: Seth Cottle Date: Mon, 17 Mar 2025 18:41:30 -0400 Subject: [PATCH 2/4] revert --- .github/contrast-check.yml | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 .github/contrast-check.yml diff --git a/.github/contrast-check.yml b/.github/contrast-check.yml deleted file mode 100644 index 58e1f40d..00000000 --- a/.github/contrast-check.yml +++ /dev/null @@ -1,23 +0,0 @@ -name: "Contrast Check" -on: - pull_request: - paths: - - 'css/brands.css' - workflow_dispatch: - -jobs: - contrast-check: - runs-on: ubuntu-latest - steps: - - name: Checkout code - uses: actions/checkout@v3 - with: - fetch-depth: 0 - - - name: Fetch main branch - run: git fetch origin main:main - - - name: Run Contrast Check - run: | - chmod +x ./scripts/audit-contrast.sh - ./scripts/audit-contrast.sh \ No newline at end of file From 3e580dbca696a783c09bb9e3178a532226da467a Mon Sep 17 00:00:00 2001 From: Seth Cottle Date: Mon, 17 Mar 2025 18:43:22 -0400 Subject: [PATCH 3/4] Create contrast-check.yml --- .github/workflows/contrast-check.yml | 32 ++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 .github/workflows/contrast-check.yml diff --git a/.github/workflows/contrast-check.yml b/.github/workflows/contrast-check.yml new file mode 100644 index 00000000..cb1edef5 --- /dev/null +++ b/.github/workflows/contrast-check.yml @@ -0,0 +1,32 @@ +name: "Contrast Check" +on: + pull_request: + paths: + - 'css/brands.css' + push: + paths: + - 'css/brands.css' + workflow_dispatch: + +jobs: + contrast-check: + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Fetch main branch + run: git fetch origin main:main + + - name: Debug information + run: | + echo "Current branch: $(git branch --show-current)" + echo "Modified files in PR:" + git diff --name-only origin/main + + - name: Run Contrast Check + run: | + chmod +x ./scripts/audit-contrast.sh + ./scripts/audit-contrast.sh From 2a384ae6ba6fcfdcb88f81936ce7ea7860fd977f Mon Sep 17 00:00:00 2001 From: Seth Cottle Date: Mon, 17 Mar 2025 18:51:05 -0400 Subject: [PATCH 4/4] Update contrast-check.yml --- .github/workflows/contrast-check.yml | 45 ++++++++++++++++++++-------- 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/.github/workflows/contrast-check.yml b/.github/workflows/contrast-check.yml index cb1edef5..6a395029 100644 --- a/.github/workflows/contrast-check.yml +++ b/.github/workflows/contrast-check.yml @@ -15,18 +15,39 @@ jobs: - name: Checkout code uses: actions/checkout@v3 with: - fetch-depth: 0 + fetch-depth: 0 # Fetch all history - - name: Fetch main branch - run: git fetch origin main:main - - - name: Debug information - run: | - echo "Current branch: $(git branch --show-current)" - echo "Modified files in PR:" - git diff --name-only origin/main - - - name: Run Contrast Check + - name: Setup for contrast check run: | + # For PR, fetch the base branch + if [[ "${{ github.event_name }}" == "pull_request" ]]; then + echo "Running on PR from ${{ github.head_ref }} to ${{ github.base_ref }}" + git fetch origin ${{ github.base_ref }}:${{ github.base_ref }} + echo "BASE_BRANCH=origin/${{ github.base_ref }}" >> $GITHUB_ENV + else + # For push or manual, use the default branch + echo "Running on push or manual trigger" + echo "BASE_BRANCH=HEAD~1" >> $GITHUB_ENV + fi + + # Make script executable chmod +x ./scripts/audit-contrast.sh - ./scripts/audit-contrast.sh + + - name: Modify contrast check script + run: | + # Create a temporary version of the script with the correct reference + grep -v "new_css=" ./scripts/audit-contrast.sh > temp.sh + + # Add the corrected git diff command + echo "# ---- FIXED GIT DIFF HANDLING ----" >> temp.sh + echo "new_css=\$(git diff $BASE_BRANCH --unified=0 -- css/brands.css | awk '/^\+.*(--button-text|--button-background|--button-border|background-image|\/\*|\.button-)/)" >> temp.sh + + # Add the rest of the original script + grep -A 1000 "if \[\[ -z \"\$new_css\" \]\]; then" ./scripts/audit-contrast.sh >> temp.sh + + # Replace the original script + mv temp.sh ./scripts/audit-contrast.sh + chmod +x ./scripts/audit-contrast.sh + + - name: Run Contrast Check + run: ./scripts/audit-contrast.sh