From f0598df57499eb3b1ac317c4af3cc4ba78ecb7bb Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Thu, 12 Dec 2024 15:44:36 -0800 Subject: [PATCH 1/2] Run repo-sync workflow only in source repo + stop workflows from being triggered by new commit in main. --- .github/workflows/codegen.yml | 2 -- .github/workflows/continuous-integration.yml | 2 -- .github/workflows/lint.yml | 2 -- .github/workflows/repo-sync.yml | 1 + 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/.github/workflows/codegen.yml b/.github/workflows/codegen.yml index 578cb3b7d..9bcce460f 100644 --- a/.github/workflows/codegen.yml +++ b/.github/workflows/codegen.yml @@ -1,8 +1,6 @@ name: Codegen on: - push: - branches: [ main ] pull_request: workflow_dispatch: diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index c58b4dbb4..dd2dd8f12 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -1,8 +1,6 @@ name: CI on: - push: - branches: [ main ] pull_request: workflow_dispatch: diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 8aaa6c8b0..fa2c3568c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,8 +1,6 @@ name: Lint on: - push: - branches: [ main ] pull_request: workflow_dispatch: diff --git a/.github/workflows/repo-sync.yml b/.github/workflows/repo-sync.yml index a789c21b5..484f7ff57 100644 --- a/.github/workflows/repo-sync.yml +++ b/.github/workflows/repo-sync.yml @@ -7,6 +7,7 @@ on: jobs: git-sync: + if: github.repository == 'smithy-lang/smithy-swift' runs-on: ubuntu-latest steps: From 7475d464121268c2e975c8a37fa05cace0cc8a50 Mon Sep 17 00:00:00 2001 From: Sichan Yoo Date: Mon, 16 Dec 2024 09:46:31 -0800 Subject: [PATCH 2/2] Make workflows run if it's being run in public repo, or it was triggered by pull request. --- .github/workflows/codegen.yml | 3 +++ .github/workflows/continuous-integration.yml | 6 ++++++ .github/workflows/lint.yml | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/.github/workflows/codegen.yml b/.github/workflows/codegen.yml index 9bcce460f..fe22c5f20 100644 --- a/.github/workflows/codegen.yml +++ b/.github/workflows/codegen.yml @@ -1,11 +1,14 @@ name: Codegen on: + push: + branches: [ main ] pull_request: workflow_dispatch: jobs: codegen: + if: github.repository == 'smithy-lang/smithy-swift' || github.event_name == 'pull_request' runs-on: ${{ matrix.os }} name: Java ${{ matrix.java }} ${{ matrix.os }} strategy: diff --git a/.github/workflows/continuous-integration.yml b/.github/workflows/continuous-integration.yml index dd2dd8f12..25cb14ced 100644 --- a/.github/workflows/continuous-integration.yml +++ b/.github/workflows/continuous-integration.yml @@ -1,6 +1,8 @@ name: CI on: + push: + branches: [ main ] pull_request: workflow_dispatch: @@ -9,6 +11,7 @@ env: jobs: apple-ci: + if: github.repository == 'smithy-lang/smithy-swift' || github.event_name == 'pull_request' runs-on: ${{ matrix.runner }} strategy: fail-fast: false @@ -101,6 +104,7 @@ jobs: | xcbeautify apple-downstream: + if: github.repository == 'smithy-lang/smithy-swift' || github.event_name == 'pull_request' runs-on: ${{ matrix.runner }} strategy: fail-fast: false @@ -221,6 +225,7 @@ jobs: | xcbeautify linux-ci: + if: github.repository == 'smithy-lang/smithy-swift' || github.event_name == 'pull_request' runs-on: ubuntu-latest strategy: fail-fast: false @@ -273,6 +278,7 @@ jobs: run: swift test linux-downstream: + if: github.repository == 'smithy-lang/smithy-swift' || github.event_name == 'pull_request' runs-on: ubuntu-latest strategy: fail-fast: false diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fa2c3568c..14d1049ca 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,11 +1,14 @@ name: Lint on: + push: + branches: [ main ] pull_request: workflow_dispatch: jobs: ktlint: + if: github.repository == 'smithy-lang/smithy-swift' || github.event_name == 'pull_request' runs-on: ubuntu-latest steps: - name: Checkout sources @@ -14,6 +17,7 @@ jobs: run: ./gradlew ktlint swiftlint: + if: github.repository == 'smithy-lang/smithy-swift' || github.event_name == 'pull_request' runs-on: ubuntu-latest container: image: ghcr.io/realm/swiftlint:0.54.0