From 2adefd861abc52cd8ec76bd3d1813d01d5945ed4 Mon Sep 17 00:00:00 2001 From: Koji Hasegawa Date: Sat, 18 Nov 2023 16:52:25 +0900 Subject: [PATCH] Fix skip jobs that cannot be running on fork --- .github/workflows/actionlint.yml | 2 +- .github/workflows/build-image.yml | 1 + .github/workflows/hadolint.yml | 2 +- .github/workflows/pr-labeler.yml | 1 + .github/workflows/release-drafter.yml | 1 + .github/workflows/shellcheck.yml | 2 +- .github/workflows/test.yml | 2 +- .github/workflows/update-major.yml | 1 + 8 files changed, 8 insertions(+), 4 deletions(-) diff --git a/.github/workflows/actionlint.yml b/.github/workflows/actionlint.yml index 3f7d19f..157d7f4 100644 --- a/.github/workflows/actionlint.yml +++ b/.github/workflows/actionlint.yml @@ -36,4 +36,4 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: failure() && github.repository_owner == 'nowsprinting' # Skip on public fork, because can not read secrets. + if: failure() && github.event.pull_request.head.repo.fork == false # Skip on public fork, because can not read secrets. diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index d09c95d..2d4f1d5 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -18,6 +18,7 @@ env: jobs: build-and-push-docker-image: + if: github.repository_owner == 'nowsprinting' # Skip on forked repo runs-on: ubuntu-latest permissions: contents: read diff --git a/.github/workflows/hadolint.yml b/.github/workflows/hadolint.yml index 6b3cfd4..2ea24b1 100644 --- a/.github/workflows/hadolint.yml +++ b/.github/workflows/hadolint.yml @@ -37,4 +37,4 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: failure() && github.repository_owner == 'nowsprinting' # Skip on public fork, because can not read secrets. + if: failure() && github.event.pull_request.head.repo.fork == false # Skip on public fork, because can not read secrets. diff --git a/.github/workflows/pr-labeler.yml b/.github/workflows/pr-labeler.yml index cccdc64..877f359 100644 --- a/.github/workflows/pr-labeler.yml +++ b/.github/workflows/pr-labeler.yml @@ -6,6 +6,7 @@ on: jobs: pr-labeler: + if: github.event.pull_request.head.repo.fork == false # Skip on public fork runs-on: ubuntu-latest permissions: contents: read diff --git a/.github/workflows/release-drafter.yml b/.github/workflows/release-drafter.yml index d1cebfe..0e4ccb2 100644 --- a/.github/workflows/release-drafter.yml +++ b/.github/workflows/release-drafter.yml @@ -12,6 +12,7 @@ concurrency: jobs: release-drafter: + if: github.repository_owner == 'nowsprinting' # Skip on forked repo runs-on: ubuntu-latest permissions: contents: write diff --git a/.github/workflows/shellcheck.yml b/.github/workflows/shellcheck.yml index 1424bab..a06b7ef 100644 --- a/.github/workflows/shellcheck.yml +++ b/.github/workflows/shellcheck.yml @@ -35,4 +35,4 @@ jobs: env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - if: failure() && github.repository_owner == 'nowsprinting' # Skip on public fork, because can not read secrets. + if: failure() && github.event.pull_request.head.repo.fork == false # Skip on public fork, because can not read secrets. diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index ca16cf4..65ab53c 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -84,7 +84,7 @@ jobs: notify: needs: [ test, test-on-container ] - if: failure() + if: failure() && github.event.pull_request.head.repo.fork == false # Skip on public fork, because can not read secrets. runs-on: ubuntu-latest permissions: actions: read diff --git a/.github/workflows/update-major.yml b/.github/workflows/update-major.yml index c6dcf22..1871ac6 100644 --- a/.github/workflows/update-major.yml +++ b/.github/workflows/update-major.yml @@ -9,6 +9,7 @@ on: jobs: update-major: + if: github.repository_owner == 'nowsprinting' # Skip on forked repo runs-on: ubuntu-latest permissions: contents: write