Skip to content

kunitsucom/github-actions-paths-ignore-alternative

Use this GitHub action with your project
Add this Action to an existing workflow or create a new one
View on Marketplace

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

81 Commits
 
 
 
 
 
 

Repository files navigation

GitHub Actions paths-ignore Alternative

A workaround workflow to resolve the incompatibility of the Require status checks to pass setting when paths-ignore is set for push trigger or pull_request trigger in GitHub Actions.

paths-ignore example

name: example

on:
  push:
    # NO paths-ignore
  pull_request:
    # NO paths-ignore
  workflow_dispatch:

jobs:
  paths-ignore:
    runs-on: ubuntu-latest
    outputs:
      skip: ${{ steps.paths-ignore.outputs.skip }}
    steps:
      - uses: kunitsucom/github-actions-paths-ignore-alternative@main
        id: paths-ignore
        with:
          paths-ignore: |-
            # substrings of file paths to ignore written in regular expressions
            ^.github/
            ^.*\.md$
            ^.*\.log$
  # > Note: A job that is skipped will report its status as "Success".
  # > It will not prevent a pull request from merging, even if it is a required check.
  # ref. https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution#overview
  not-skip:
    runs-on: ubuntu-latest
    needs: paths-ignore
    if: ${{ needs.paths-ignore.outputs.skip != 'true' }}
    steps:
      - name: "if not skip"
        run: |
            echo "needs.paths-ignore.outputs.skip: ${{ needs.paths-ignore.outputs.skip }}"
  skip:
    runs-on: ubuntu-latest
    needs: paths-ignore
    if: ${{ needs.paths-ignore.outputs.skip == 'true' }}
    steps:
      - name: "if skip"
        run: |
            echo "needs.paths-ignore.outputs.skip: ${{ needs.paths-ignore.outputs.skip }}"

paths example

name: example

on:
  push:
    # NO paths-ignore
  pull_request:
    # NO paths-ignore
  workflow_dispatch:

jobs:
  paths-ignore:
    runs-on: ubuntu-latest
    outputs:
      skip: ${{ steps.paths-ignore.outputs.skip }}
    steps:
      - uses: kunitsucom/github-actions-paths-ignore-alternative@main
        id: paths-ignore
        with:
          paths: |-
            # If any of these regular expressions match, it returns skip=false
            # This setting takes precedence over paths-ignore
            ^action.yml
  # > Note: A job that is skipped will report its status as "Success".
  # > It will not prevent a pull request from merging, even if it is a required check.
  # ref. https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution#overview
  not-skip:
    runs-on: ubuntu-latest
    needs: paths-ignore
    if: ${{ needs.paths-ignore.outputs.skip != 'true' }}
    steps:
      - name: "if not skip"
        run: |
            echo "needs.paths-ignore.outputs.skip: ${{ needs.paths-ignore.outputs.skip }}"
  skip:
    runs-on: ubuntu-latest
    needs: paths-ignore
    if: ${{ needs.paths-ignore.outputs.skip == 'true' }}
    steps:
      - name: "if skip"
        run: |
            echo "needs.paths-ignore.outputs.skip: ${{ needs.paths-ignore.outputs.skip }}"