From a2a7ab0be3aff8f94f580050ff8eab85ae255167 Mon Sep 17 00:00:00 2001 From: walkowif <59475134+walkowif@users.noreply.github.com> Date: Tue, 12 Mar 2024 13:56:35 +0100 Subject: [PATCH] Fix honoring skip phrases (#217) --- .github/workflows/audit.yaml | 29 +++++++++++ .github/workflows/bioccheck.yaml | 14 ++++++ .github/workflows/build-check-install.yaml | 55 +++++++++++++-------- .github/workflows/gitleaks.yaml | 56 ++++++++++++++++++++++ .github/workflows/grammar.yaml | 29 ++++++++++- .github/workflows/licenses.yaml | 28 +++++++++++ .github/workflows/links.yaml | 27 +++++++++++ .github/workflows/linter.yaml | 50 +++++++++++++++++++ .github/workflows/pkgdown.yaml | 16 +++++++ .github/workflows/release.yaml | 14 ++++++ .github/workflows/roxygen.yaml | 14 ++++++ .github/workflows/spelling.yaml | 30 +++++++++++- .github/workflows/style.yaml | 27 ++++++++++- .github/workflows/test-coverage.yaml | 39 +++++++++++++++ .github/workflows/validation.yaml | 27 +++++++++++ .github/workflows/verdepcheck.yaml | 22 ++++++++- .github/workflows/version-bump.yaml | 5 ++ .github/workflows/version.yaml | 55 +++++++++++++++++++++ 18 files changed, 512 insertions(+), 25 deletions(-) diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml index b9882d8c..6ddf6db0 100644 --- a/.github/workflows/audit.yaml +++ b/.github/workflows/audit.yaml @@ -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 diff --git a/.github/workflows/bioccheck.yaml b/.github/workflows/bioccheck.yaml index cf5408fd..d79b4179 100644 --- a/.github/workflows/bioccheck.yaml +++ b/.github/workflows/bioccheck.yaml @@ -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: diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 0e981fd8..46d269d5 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -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 @@ -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 @@ -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 diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml index 7b791fe0..07c8223d 100644 --- a/.github/workflows/gitleaks.yaml +++ b/.github/workflows/gitleaks.yaml @@ -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: | @@ -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: diff --git a/.github/workflows/grammar.yaml b/.github/workflows/grammar.yaml index aa8403a3..e2a16a7d 100644 --- a/.github/workflows/grammar.yaml +++ b/.github/workflows/grammar.yaml @@ -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 diff --git a/.github/workflows/licenses.yaml b/.github/workflows/licenses.yaml index 4daa53ea..bf105903 100644 --- a/.github/workflows/licenses.yaml +++ b/.github/workflows/licenses.yaml @@ -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 diff --git a/.github/workflows/links.yaml b/.github/workflows/links.yaml index 3a1e664e..403ca526 100644 --- a/.github/workflows/links.yaml +++ b/.github/workflows/links.yaml @@ -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/lychee-action@v1.8.0 diff --git a/.github/workflows/linter.yaml b/.github/workflows/linter.yaml index 44bf8696..88d45551 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -38,12 +38,40 @@ jobs: if: > !contains(github.event.commits[0].message, '[skip linter]') && 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: 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 linter]" + - name: Override SuperLinter configs 💾 run: | # Override markdownlint default config @@ -90,12 +118,34 @@ jobs: && github.event.pull_request.draft == false container: image: ghcr.io/insightsengineering/rstudio:latest + steps: + - name: Checkout repo (PR) 🛎 + uses: actions/checkout@v4 + if: github.event_name == 'pull_request' + with: + ref: ${{ github.event.pull_request.head.sha }} + fetch-depth: 0 + - name: Checkout repo 🛎 uses: actions/checkout@v4 + if: github.event_name != 'pull_request' with: 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 linter]" + - name: Changed files 🖋️ id: files uses: Ana06/get-changed-files@v2.2.0 diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 5b2c70ae..7e18c672 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -125,9 +125,11 @@ jobs: && github.event.pull_request.draft == false container: image: ghcr.io/insightsengineering/rstudio:latest + # Only one job can publish to gh-pages branch concurrently. concurrency: group: ghpages + steps: - name: Setup token 🔑 id: github-token @@ -172,6 +174,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 docs]" + - name: Restore SD cache 💰 uses: actions/cache@v4 with: diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fd6c64cf..543cd005 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -35,6 +35,7 @@ jobs: if: "! contains(github.event.commits[0].message, '[skip release]')" permissions: contents: write + steps: - name: Setup token 🔑 id: github-token @@ -51,6 +52,19 @@ jobs: - name: Checkout repo 🛎 uses: actions/checkout@v4 + - 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 release]" + - name: Get branch names 🌿 id: branch-name uses: tj-actions/branch-names@v7 diff --git a/.github/workflows/roxygen.yaml b/.github/workflows/roxygen.yaml index 92947fae..5020d230 100644 --- a/.github/workflows/roxygen.yaml +++ b/.github/workflows/roxygen.yaml @@ -94,6 +94,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 roxygen]" + - name: Restore SD cache 💰 uses: actions/cache@v4 with: diff --git a/.github/workflows/spelling.yaml b/.github/workflows/spelling.yaml index 4903b751..8d1e335a 100644 --- a/.github/workflows/spelling.yaml +++ b/.github/workflows/spelling.yaml @@ -58,11 +58,39 @@ jobs: fi shell: bash - - 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 }} + fetch-depth: 1 + token: ${{ steps.github-token.outputs.token }} + + - name: Checkout repo 🛎 uses: actions/checkout@v4 + if: github.event_name != 'pull_request' with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} token: ${{ steps.github-token.outputs.token }} + - 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 spelling]" + - name: Normalize variables 📏 run: | package_subdirectory_input="${{ inputs.package-subdirectory }}" diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml index ab094d1d..5a24b8a8 100644 --- a/.github/workflows/style.yaml +++ b/.github/workflows/style.yaml @@ -60,17 +60,40 @@ jobs: shell: bash - name: Get branch names 🌿 - if: inputs.auto-update id: branch-name uses: tj-actions/branch-names@v7 - - name: Checkout Code 🛎 + - 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 }} fetch-depth: 0 token: ${{ steps.github-token.outputs.token }} + + - 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 }} + token: ${{ steps.github-token.outputs.token }} + + - 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 style]" - name: Install styler 👚 run: | diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index e97d0995..f3aba70e 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -108,6 +108,7 @@ jobs: is-latest-tag: ${{ steps.current-branch-or-tag.outputs.is-latest-tag }} is-rc-tag: ${{ steps.current-branch-or-tag.outputs.is-rc-tag }} multiversion-docs: ${{ steps.current-branch-or-tag.outputs.multiversion-docs }} + steps: - name: Setup token 🔑 id: github-token @@ -180,6 +181,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 coverage]" + - name: Normalize inputs ⊳ id: normalizer shell: bash @@ -311,17 +326,41 @@ jobs: && contains(inputs.enable-covtracer, 'true') container: image: ghcr.io/insightsengineering/rstudio:latest + 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 }} + path: ${{ github.event.repository.name }} + 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 }} 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 coverage]" + - name: Restore SD cache 💰 uses: actions/cache@v4 with: diff --git a/.github/workflows/validation.yaml b/.github/workflows/validation.yaml index 872b163a..33e95151 100644 --- a/.github/workflows/validation.yaml +++ b/.github/workflows/validation.yaml @@ -74,8 +74,35 @@ jobs: fi shell: bash + - 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 validation]" - name: Normalize variables 📏 run: | diff --git a/.github/workflows/verdepcheck.yaml b/.github/workflows/verdepcheck.yaml index b7102f9d..5c352207 100644 --- a/.github/workflows/verdepcheck.yaml +++ b/.github/workflows/verdepcheck.yaml @@ -62,8 +62,28 @@ jobs: fi shell: bash - - name: Checkout Code 🛎 + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + + - name: Checkout repo 🛎 uses: actions/checkout@v4 + 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 dependency-test]" - name: Normalize variables 📏 run: | diff --git a/.github/workflows/version-bump.yaml b/.github/workflows/version-bump.yaml index 1a8be349..cf1b7c9b 100644 --- a/.github/workflows/version-bump.yaml +++ b/.github/workflows/version-bump.yaml @@ -56,9 +56,14 @@ jobs: fi shell: bash + - name: Get branch names 🌿 + id: branch-name + uses: tj-actions/branch-names@v7 + - name: Checkout repo 🛎 uses: actions/checkout@v4 with: + ref: ${{ steps.branch-name.outputs.head_ref_branch }} token: ${{ steps.github-token.outputs.token }} - name: Bump version in DESCRIPTION 📜 diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index 2ea74f72..58264edf 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -33,9 +33,37 @@ jobs: if: > !contains(github.event.commits[0].message, '[skip version]') && 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 version]" - name: NEWS.md and DESCRIPTION Version check 🏁 run: | @@ -70,8 +98,35 @@ jobs: !contains(github.event.commits[0].message, '[skip version]') && 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 version]" - name: Set up Python 🐍 uses: actions/setup-python@v5