Skip to content

Commit

Permalink
Fix honoring skip phrases (#217)
Browse files Browse the repository at this point in the history
  • Loading branch information
walkowif authored Mar 12, 2024
1 parent d22280e commit a2a7ab0
Show file tree
Hide file tree
Showing 18 changed files with 512 additions and 25 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/audit.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,37 @@ jobs:
!contains(github.event.commits[0].message, '[skip audit]')
&& github.event.pull_request.draft == false
steps:
- name: Get branch names 🌿
id: branch-name
uses: tj-actions/branch-names@v7

- name: Checkout repo (PR) 🛎
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 1

- name: Checkout repo 🛎
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
fetch-depth: 1

- name: Check commit message 💬
run: |
git config --global --add safe.directory $(pwd)
export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')"
echo "head_commit_message = $head_commit_message"
if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then
echo "Skip instruction detected - cancelling the workflow."
exit 1
fi
shell: bash
env:
SKIP_INSTRUCTION: "[skip audit]"

- name: Normalize inputs 🛠️
id: normalizer
Expand Down
14 changes: 14 additions & 0 deletions .github/workflows/bioccheck.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,20 @@ jobs:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
path: ${{ github.event.repository.name }}

- name: Check commit message 💬
run: |
git config --global --add safe.directory $(pwd)
export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')"
echo "head_commit_message = $head_commit_message"
if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then
echo "Skip instruction detected - cancelling the workflow."
exit 1
fi
shell: bash
working-directory: ${{ github.event.repository.name }}
env:
SKIP_INSTRUCTION: "[skip bioccheck]"

- name: Restore SD cache 💰
uses: actions/cache@v4
with:
Expand Down
55 changes: 35 additions & 20 deletions .github/workflows/build-check-install.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,40 @@ jobs:
id: branch-name
uses: tj-actions/branch-names@v7

- name: Checkout repo (PR) 🛎
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
path: ${{ github.event.repository.name }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
# When fetch-depth is set to 1 (default), and if additional commits are added
# to the branch between this step and the 'Set TESTING_DEPTH' step, git might fail
# referencing ${{ github.event.after }} commit
# because it's not the latest commit fetched by this step.
fetch-depth: 0

- name: Checkout repo 🛎
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
path: ${{ github.event.repository.name }}

- name: Check commit message 💬
run: |
git config --global --add safe.directory $(pwd)
export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')"
echo "head_commit_message = $head_commit_message"
if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then
echo "Skip instruction detected - cancelling the workflow."
exit 1
fi
shell: bash
working-directory: ${{ github.event.repository.name }}
env:
SKIP_INSTRUCTION: "[skip r-cmd]"

- name: Checkout gh-pages 🛎
if: >-
inputs.publish-unit-test-report-gh-pages == true
Expand Down Expand Up @@ -301,26 +335,6 @@ jobs:
run: npm i -g xunit-viewer
shell: bash

- name: Checkout repo (PR) 🛎
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
path: ${{ github.event.repository.name }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
# When fetch-depth is set to 1 (default), and if additional commits are added
# to the branch between this step and the 'Set TESTING_DEPTH' step, git might fail
# referencing ${{ github.event.after }} commit
# because it's not the latest commit fetched by this step.
fetch-depth: 0

- name: Checkout repo 🛎
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
path: ${{ github.event.repository.name }}

- name: Restore SD cache 💰
if: inputs.install-deps-from-package-repositories == ''
uses: actions/cache@v4
Expand Down Expand Up @@ -843,6 +857,7 @@ jobs:
startsWith(github.ref, 'refs/tags/v')
&& (!contains(github.event.commits[0].message, '[skip r-cmd]'))
&& github.event.pull_request.draft == false
steps:
- name: Checkout repo 🛎
uses: actions/checkout@v4
Expand Down
56 changes: 56 additions & 0 deletions .github/workflows/gitleaks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,37 @@ jobs:
if: >
!contains(github.event.commits[0].message, '[skip gitleaks]')
&& github.event.pull_request.draft == false
steps:
- name: Get branch names 🌿
id: branch-name
uses: tj-actions/branch-names@v7

- name: Checkout repo (PR) 🛎
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Checkout repo 🛎
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}

- name: Check commit message 💬
run: |
git config --global --add safe.directory $(pwd)
export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')"
echo "head_commit_message = $head_commit_message"
if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then
echo "Skip instruction detected - cancelling the workflow."
exit 1
fi
shell: bash
env:
SKIP_INSTRUCTION: "[skip gitleaks]"

- name: Download and install gitleaks 💧
run: |
Expand Down Expand Up @@ -68,12 +96,40 @@ jobs:
!contains(github.event.commits[0].message, '[skip pii-check]')
&& github.event.pull_request.draft == false
&& inputs.check-for-pii == true
steps:
- name: Get branch names 🌿
id: branch-name
uses: tj-actions/branch-names@v7

- name: Checkout repo (PR) 🛎
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
repository: ${{ github.event.pull_request.head.repo.full_name }}
fetch-depth: 0

- name: Checkout repo 🛎
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
fetch-depth: 0

- name: Check commit message 💬
run: |
git config --global --add safe.directory $(pwd)
export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')"
echo "head_commit_message = $head_commit_message"
if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then
echo "Skip instruction detected - cancelling the workflow."
exit 1
fi
shell: bash
env:
SKIP_INSTRUCTION: "[skip pii-check]"

- name: Run Presidio to check for PII ☔
uses: insightsengineering/presidio-action@v1
with:
Expand Down
29 changes: 28 additions & 1 deletion .github/workflows/grammar.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,35 @@ jobs:
&& github.event.pull_request.draft == false
steps:
- name: Checkout Code 🛎
- name: Get branch names 🌿
id: branch-name
uses: tj-actions/branch-names@v7

- name: Checkout repo (PR) 🛎
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Checkout repo 🛎
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}

- name: Check commit message 💬
run: |
git config --global --add safe.directory $(pwd)
export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')"
echo "head_commit_message = $head_commit_message"
if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then
echo "Skip instruction detected - cancelling the workflow."
exit 1
fi
shell: bash
env:
SKIP_INSTRUCTION: "[skip grammar]"

- name: Restore npm cache 💰
uses: actions/cache@v4
Expand Down
28 changes: 28 additions & 0 deletions .github/workflows/licenses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,37 @@ jobs:
if: >
!contains(github.event.commits[0].message, '[skip licenses]')
&& github.event.pull_request.draft == false
steps:
- name: Get branch names 🌿
id: branch-name
uses: tj-actions/branch-names@v7

- name: Checkout repo (PR) 🛎
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Checkout repo 🛎
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}

- name: Check commit message 💬
run: |
git config --global --add safe.directory $(pwd)
export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')"
echo "head_commit_message = $head_commit_message"
if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then
echo "Skip instruction detected - cancelling the workflow."
exit 1
fi
shell: bash
env:
SKIP_INSTRUCTION: "[skip licenses]"

- name: Generate license report 📜
uses: insightsengineering/r-license-report@v1
Expand Down
27 changes: 27 additions & 0 deletions .github/workflows/links.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,35 @@ jobs:
!contains(github.event.commits[0].message, '[skip links]')
&& github.event.pull_request.draft == false
steps:
- name: Get branch names 🌿
id: branch-name
uses: tj-actions/branch-names@v7

- name: Checkout repo (PR) 🛎
uses: actions/checkout@v4
if: github.event_name == 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}
repository: ${{ github.event.pull_request.head.repo.full_name }}

- name: Checkout repo 🛎
uses: actions/checkout@v4
if: github.event_name != 'pull_request'
with:
ref: ${{ steps.branch-name.outputs.head_ref_branch }}

- name: Check commit message 💬
run: |
git config --global --add safe.directory $(pwd)
export head_commit_message="$(git show -s --format=%B | tr '\r\n' ' ' | tr '\n' ' ')"
echo "head_commit_message = $head_commit_message"
if [[ $head_commit_message == *"$SKIP_INSTRUCTION"* ]]; then
echo "Skip instruction detected - cancelling the workflow."
exit 1
fi
shell: bash
env:
SKIP_INSTRUCTION: "[skip links]"

- name: Check URLs in docs 🔬
uses: lycheeverse/[email protected]
Expand Down
Loading

0 comments on commit a2a7ab0

Please sign in to comment.