diff --git a/.github/workflows/audit.yaml b/.github/workflows/audit.yaml index ef941db3..d073bbfb 100644 --- a/.github/workflows/audit.yaml +++ b/.github/workflows/audit.yaml @@ -66,6 +66,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: diff --git a/.github/workflows/bioccheck.yaml b/.github/workflows/bioccheck.yaml index 7607a932..2df35f3f 100644 --- a/.github/workflows/bioccheck.yaml +++ b/.github/workflows/bioccheck.yaml @@ -118,6 +118,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: diff --git a/.github/workflows/build-check-install.yaml b/.github/workflows/build-check-install.yaml index 1c6488d8..9751e7a3 100644 --- a/.github/workflows/build-check-install.yaml +++ b/.github/workflows/build-check-install.yaml @@ -243,6 +243,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: @@ -250,12 +252,6 @@ jobs: GH_CLI_VERSION: 2.44.1 SKIP_INSTRUCTION: "[skip r-cmd]" - # - name: Check commit message 💬 - # uses: ./r.pkg.template/.github/workflows/check-commit-message - # with: - # github-token: ${{ steps.github-token.outputs.token }} - # skip-instruction: "[skip r-cmd]" - - name: Checkout gh-pages 🛎 if: >- inputs.publish-unit-test-report-gh-pages == true @@ -859,12 +855,44 @@ jobs: runs-on: ubuntu-latest if: > startsWith(github.ref, 'refs/tags/v') - && (!contains(github.event.commits[0].message, '[skip r-cmd]')) && github.event.pull_request.draft == false steps: + - name: Setup token 🔑 + id: github-token + run: | + if [ "${{ secrets.REPO_GITHUB_TOKEN }}" == "" ]; then + echo "REPO_GITHUB_TOKEN is empty. Substituting it with GITHUB_TOKEN." + echo "token=${{ secrets.GITHUB_TOKEN }}" >> $GITHUB_OUTPUT + else + echo "Using REPO_GITHUB_TOKEN." + echo "token=${{ secrets.REPO_GITHUB_TOKEN }}" >> $GITHUB_OUTPUT + fi + shell: bash + - 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." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." + fi + shell: bash + env: + GH_TOKEN: ${{ steps.github-token.outputs.token }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip r-cmd]" + - name: Get package build filename 📦 run: | echo "PKGBUILD=$(echo $(awk -F: '/Package:/{gsub(/[ ]+/,"") ; print $2}' DESCRIPTION)_"\ diff --git a/.github/workflows/gitleaks.yaml b/.github/workflows/gitleaks.yaml index c33dc673..a2b282f7 100644 --- a/.github/workflows/gitleaks.yaml +++ b/.github/workflows/gitleaks.yaml @@ -68,6 +68,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: @@ -133,6 +135,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: diff --git a/.github/workflows/grammar.yaml b/.github/workflows/grammar.yaml index aa8403a3..91fa5db6 100644 --- a/.github/workflows/grammar.yaml +++ b/.github/workflows/grammar.yaml @@ -35,12 +35,46 @@ jobs: name: Check 📝 runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip grammar]') - && github.event.pull_request.draft == false + 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." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." + fi + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_VERSION: 2.44.1 + 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 a62f1674..d1982c2c 100644 --- a/.github/workflows/licenses.yaml +++ b/.github/workflows/licenses.yaml @@ -62,6 +62,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: diff --git a/.github/workflows/links.yaml b/.github/workflows/links.yaml index 3a1e664e..1ab3dfea 100644 --- a/.github/workflows/links.yaml +++ b/.github/workflows/links.yaml @@ -31,11 +31,45 @@ jobs: name: Validate Links 🔎 runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip links]') - && github.event.pull_request.draft == false + 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." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." + fi + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_VERSION: 2.44.1 + 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 4c9913c7..5f1fb0a0 100644 --- a/.github/workflows/linter.yaml +++ b/.github/workflows/linter.yaml @@ -75,6 +75,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: @@ -154,6 +156,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 5b2c70ae..8484e4db 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -121,13 +121,14 @@ jobs: name: Generate 🐣 runs-on: ubuntu-latest if: > - !contains(github.event.commits[0].message, '[skip docs]') - && github.event.pull_request.draft == false + 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 +173,27 @@ 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." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." + fi + shell: bash + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + GH_CLI_VERSION: 2.44.1 + SKIP_INSTRUCTION: "[skip docs]" + - name: Restore SD cache 💰 uses: actions/cache@v4 with: @@ -280,8 +302,7 @@ jobs: concurrency: group: ghpages if: > - (github.event_name == 'push' || github.event_name == 'workflow_dispatch') - && !contains(github.event.commits[0].message, '[skip docs]') + github.event_name == 'push' || github.event_name == 'workflow_dispatch' steps: - name: Checkout repo 🛎 uses: actions/checkout@v4 @@ -317,7 +338,6 @@ jobs: runs-on: ubuntu-latest if: > startsWith(github.ref, 'refs/tags/v') - && !contains(github.event.commits[0].message, '[skip docs]') steps: - name: Checkout repo 🛎 uses: actions/checkout@v4 diff --git a/.github/workflows/release.yaml b/.github/workflows/release.yaml index fd6c64cf..02a3c57b 100644 --- a/.github/workflows/release.yaml +++ b/.github/workflows/release.yaml @@ -32,9 +32,9 @@ jobs: release: name: Release 🚀 runs-on: ubuntu-latest - if: "! contains(github.event.commits[0].message, '[skip release]')" permissions: contents: write + steps: - name: Setup token 🔑 id: github-token @@ -51,6 +51,27 @@ 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." + curl -s -LJ -o gh.tar.gz https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/gh_${GH_CLI_VERSION}_linux_amd64.tar.gz + tar -xzf gh.tar.gz --strip-components 2 + ./gh version + ./gh run cancel ${{ github.run_id }} + ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." + fi + shell: bash + env: + GH_TOKEN: ${{ steps.github-token.outputs.token }} + GH_CLI_VERSION: 2.44.1 + 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 c73df6cb..c10681b2 100644 --- a/.github/workflows/roxygen.yaml +++ b/.github/workflows/roxygen.yaml @@ -5,15 +5,14 @@ on: push: branches: - main - - debug-skip-phrases - # pull_request: - # types: - # - opened - # - synchronize - # - reopened - # - ready_for_review - # branches: - # - main + pull_request: + types: + - opened + - synchronize + - reopened + - ready_for_review + branches: + - main workflow_dispatch: workflow_call: inputs: @@ -113,6 +112,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash working-directory: ${{ github.event.repository.name }} diff --git a/.github/workflows/spelling.yaml b/.github/workflows/spelling.yaml index efd7fc1b..a91c1ab7 100644 --- a/.github/workflows/spelling.yaml +++ b/.github/workflows/spelling.yaml @@ -89,6 +89,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml index b5bf427d..eb0d5f8c 100644 --- a/.github/workflows/style.yaml +++ b/.github/workflows/style.yaml @@ -92,6 +92,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 114bd19b..92401cc9 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -192,6 +192,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: @@ -362,6 +364,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash working-directory: ${{ github.event.repository.name }} diff --git a/.github/workflows/validation.yaml b/.github/workflows/validation.yaml index c853ed11..aa3cfd34 100644 --- a/.github/workflows/validation.yaml +++ b/.github/workflows/validation.yaml @@ -102,6 +102,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: diff --git a/.github/workflows/verdepcheck.yaml b/.github/workflows/verdepcheck.yaml index 660f6199..985fa14c 100644 --- a/.github/workflows/verdepcheck.yaml +++ b/.github/workflows/verdepcheck.yaml @@ -83,6 +83,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: diff --git a/.github/workflows/version-bump.yaml b/.github/workflows/version-bump.yaml index 05c8654b..bf34ac24 100644 --- a/.github/workflows/version-bump.yaml +++ b/.github/workflows/version-bump.yaml @@ -74,6 +74,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: diff --git a/.github/workflows/version.yaml b/.github/workflows/version.yaml index 86ae56bb..37133777 100644 --- a/.github/workflows/version.yaml +++ b/.github/workflows/version.yaml @@ -63,6 +63,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: @@ -131,6 +133,8 @@ jobs: ./gh version ./gh run cancel ${{ github.run_id }} ./gh run watch ${{ github.run_id }} + else + echo "Skip instruction not detected - continuing the workflow." fi shell: bash env: