From 011d66ef8be2c616cdfa0cd94fecb265b06bbbe7 Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 19 Dec 2024 08:22:15 +0100 Subject: [PATCH 1/7] fix(gha): change exit 0 to 1 when checking repos --- .github/workflows/api-build-lint-push-containers.yml | 2 +- .github/workflows/ui-build-lint-push-containers.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/api-build-lint-push-containers.yml b/.github/workflows/api-build-lint-push-containers.yml index 0951f22eca4..09625d74211 100644 --- a/.github/workflows/api-build-lint-push-containers.yml +++ b/.github/workflows/api-build-lint-push-containers.yml @@ -42,7 +42,7 @@ jobs: - name: Repository check working-directory: /tmp run: | - [[ ${{ github.repository }} != "prowler-cloud/prowler" ]] && echo "This action only runs for prowler-cloud/prowler"; exit 0 + [[ ${{ github.repository }} != "prowler-cloud/prowler" ]] && echo "This action only runs for prowler-cloud/prowler"; exit 1 - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/ui-build-lint-push-containers.yml b/.github/workflows/ui-build-lint-push-containers.yml index 41c0a11017c..c8cd8c86973 100644 --- a/.github/workflows/ui-build-lint-push-containers.yml +++ b/.github/workflows/ui-build-lint-push-containers.yml @@ -42,7 +42,7 @@ jobs: - name: Repository check working-directory: /tmp run: | - [[ ${{ github.repository }} != "prowler-cloud/prowler" ]] && echo "This action only runs for prowler-cloud/prowler"; exit 0 + [[ ${{ github.repository }} != "prowler-cloud/prowler" ]] && echo "This action only runs for prowler-cloud/prowler"; exit 1 - name: Checkout uses: actions/checkout@v4 From 846f355b6b145c9b9de596c4489fc64a0ac558c7 Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 19 Dec 2024 08:42:57 +0100 Subject: [PATCH 2/7] chore(gha): add repo check in job --- .../ui-build-lint-push-containers.yml | 25 +++++++++++++++---- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/.github/workflows/ui-build-lint-push-containers.yml b/.github/workflows/ui-build-lint-push-containers.yml index c8cd8c86973..0b52f485096 100644 --- a/.github/workflows/ui-build-lint-push-containers.yml +++ b/.github/workflows/ui-build-lint-push-containers.yml @@ -31,19 +31,34 @@ env: PROWLERCLOUD_DOCKERHUB_IMAGE: prowler-ui jobs: + repository-check: + name: Repository check + runs-on: ubuntu-latest + outputs: + is_repo: ${{ steps.repository_check.outputs.is_repo }} + steps: + - name: Repository check + id: repository_check + working-directory: /tmp + run: | + if [[ ${{ github.repository }} == "prowler-cloud/prowler" ]] + then + echo "This action only runs for prowler-cloud/prowler" + echo "is_repo=true" >> "${GITHUB_OUTPUT}" + else + echo "is_repo=false" >> "${GITHUB_OUTPUT}" + fi + # Build Prowler OSS container container-build-push: + needs: repository-check + if: needs.repository-check.outputs.is_repo == 'true' runs-on: ubuntu-latest defaults: run: working-directory: ${{ env.WORKING_DIRECTORY }} steps: - - name: Repository check - working-directory: /tmp - run: | - [[ ${{ github.repository }} != "prowler-cloud/prowler" ]] && echo "This action only runs for prowler-cloud/prowler"; exit 1 - - name: Checkout uses: actions/checkout@v4 From 6ff3c28e6665cfad4fba0c0cc193f159fc13ef47 Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 19 Dec 2024 08:45:04 +0100 Subject: [PATCH 3/7] chore: test --- .github/workflows/ui-build-lint-push-containers.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ui-build-lint-push-containers.yml b/.github/workflows/ui-build-lint-push-containers.yml index 0b52f485096..44bba652339 100644 --- a/.github/workflows/ui-build-lint-push-containers.yml +++ b/.github/workflows/ui-build-lint-push-containers.yml @@ -9,12 +9,12 @@ on: - ".github/workflows/ui-build-lint-push-containers.yml" # Uncomment the below code to test this action on PRs - # pull_request: - # branches: - # - "master" - # paths: - # - "ui/**" - # - ".github/workflows/ui-build-lint-push-containers.yml" + pull_request: + branches: + - "master" + paths: + - "ui/**" + - ".github/workflows/ui-build-lint-push-containers.yml" release: types: [published] From bb8031c412fab5e24b40a4f879ba961053bfb28d Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 19 Dec 2024 08:47:41 +0100 Subject: [PATCH 4/7] chore: test --- .github/workflows/ui-build-lint-push-containers.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ui-build-lint-push-containers.yml b/.github/workflows/ui-build-lint-push-containers.yml index 44bba652339..7d33d31a77d 100644 --- a/.github/workflows/ui-build-lint-push-containers.yml +++ b/.github/workflows/ui-build-lint-push-containers.yml @@ -43,9 +43,9 @@ jobs: run: | if [[ ${{ github.repository }} == "prowler-cloud/prowler" ]] then - echo "This action only runs for prowler-cloud/prowler" - echo "is_repo=true" >> "${GITHUB_OUTPUT}" + echo "is_repo=false" >> "${GITHUB_OUTPUT}" else + echo "This action only runs for prowler-cloud/prowler" echo "is_repo=false" >> "${GITHUB_OUTPUT}" fi From 29581bf3b42b0c329dadf238a91d8b413d587281 Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 19 Dec 2024 08:50:13 +0100 Subject: [PATCH 5/7] chore(gha): add repo check in job --- .../api-build-lint-push-containers.yml | 37 +++++++++++++------ .../ui-build-lint-push-containers.yml | 14 +++---- 2 files changed, 33 insertions(+), 18 deletions(-) diff --git a/.github/workflows/api-build-lint-push-containers.yml b/.github/workflows/api-build-lint-push-containers.yml index 09625d74211..4428125ee89 100644 --- a/.github/workflows/api-build-lint-push-containers.yml +++ b/.github/workflows/api-build-lint-push-containers.yml @@ -9,12 +9,12 @@ on: - ".github/workflows/api-build-lint-push-containers.yml" # Uncomment the code below to test this action on PRs - # pull_request: - # branches: - # - "master" - # paths: - # - "api/**" - # - ".github/workflows/api-build-lint-push-containers.yml" + pull_request: + branches: + - "master" + paths: + - "api/**" + - ".github/workflows/api-build-lint-push-containers.yml" release: types: [published] @@ -31,19 +31,34 @@ env: PROWLERCLOUD_DOCKERHUB_IMAGE: prowler-api jobs: + repository-check: + name: Repository check + runs-on: ubuntu-latest + outputs: + is_repo: ${{ steps.repository_check.outputs.is_repo }} + steps: + - name: Repository check + id: repository_check + working-directory: /tmp + run: | + if [[ ${{ github.repository }} == "prowler-cloud/prowler" ]] + then + echo "is_repo=true" >> "${GITHUB_OUTPUT}" + else + echo "This action only runs for prowler-cloud/prowler" + echo "is_repo=false" >> "${GITHUB_OUTPUT}" + fi + # Build Prowler OSS container container-build-push: + needs: repository-check + if: needs.repository-check.outputs.is_repo == 'true' runs-on: ubuntu-latest defaults: run: working-directory: ${{ env.WORKING_DIRECTORY }} steps: - - name: Repository check - working-directory: /tmp - run: | - [[ ${{ github.repository }} != "prowler-cloud/prowler" ]] && echo "This action only runs for prowler-cloud/prowler"; exit 1 - - name: Checkout uses: actions/checkout@v4 diff --git a/.github/workflows/ui-build-lint-push-containers.yml b/.github/workflows/ui-build-lint-push-containers.yml index 7d33d31a77d..23686363977 100644 --- a/.github/workflows/ui-build-lint-push-containers.yml +++ b/.github/workflows/ui-build-lint-push-containers.yml @@ -9,12 +9,12 @@ on: - ".github/workflows/ui-build-lint-push-containers.yml" # Uncomment the below code to test this action on PRs - pull_request: - branches: - - "master" - paths: - - "ui/**" - - ".github/workflows/ui-build-lint-push-containers.yml" + # pull_request: + # branches: + # - "master" + # paths: + # - "ui/**" + # - ".github/workflows/ui-build-lint-push-containers.yml" release: types: [published] @@ -43,7 +43,7 @@ jobs: run: | if [[ ${{ github.repository }} == "prowler-cloud/prowler" ]] then - echo "is_repo=false" >> "${GITHUB_OUTPUT}" + echo "is_repo=true" >> "${GITHUB_OUTPUT}" else echo "This action only runs for prowler-cloud/prowler" echo "is_repo=false" >> "${GITHUB_OUTPUT}" From e0b756ab2c5610cc59621ee50773147dfd6badc0 Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 19 Dec 2024 08:51:16 +0100 Subject: [PATCH 6/7] chore: remove test --- .github/workflows/api-build-lint-push-containers.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/api-build-lint-push-containers.yml b/.github/workflows/api-build-lint-push-containers.yml index 4428125ee89..5aaec3c4550 100644 --- a/.github/workflows/api-build-lint-push-containers.yml +++ b/.github/workflows/api-build-lint-push-containers.yml @@ -9,12 +9,12 @@ on: - ".github/workflows/api-build-lint-push-containers.yml" # Uncomment the code below to test this action on PRs - pull_request: - branches: - - "master" - paths: - - "api/**" - - ".github/workflows/api-build-lint-push-containers.yml" + # pull_request: + # branches: + # - "master" + # paths: + # - "api/**" + # - ".github/workflows/api-build-lint-push-containers.yml" release: types: [published] From 82cf948aa73d20e8102096d5ffb89cb91fd90348 Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 19 Dec 2024 08:54:53 +0100 Subject: [PATCH 7/7] chore(gha): add repo check in job for pypi --- .github/workflows/sdk-pypi-release.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/.github/workflows/sdk-pypi-release.yml b/.github/workflows/sdk-pypi-release.yml index 4d9c91d6904..b99ce46ea5b 100644 --- a/.github/workflows/sdk-pypi-release.yml +++ b/.github/workflows/sdk-pypi-release.yml @@ -10,12 +10,37 @@ env: CACHE: "poetry" jobs: + repository-check: + name: Repository check + runs-on: ubuntu-latest + outputs: + is_repo: ${{ steps.repository_check.outputs.is_repo }} + steps: + - name: Repository check + id: repository_check + working-directory: /tmp + run: | + if [[ ${{ github.repository }} == "prowler-cloud/prowler" ]] + then + echo "is_repo=true" >> "${GITHUB_OUTPUT}" + else + echo "This action only runs for prowler-cloud/prowler" + echo "is_repo=false" >> "${GITHUB_OUTPUT}" + fi + release-prowler-job: runs-on: ubuntu-latest + needs: repository-check + if: needs.repository-check.outputs.is_repo == 'true' env: POETRY_VIRTUALENVS_CREATE: "false" name: Release Prowler to PyPI steps: + - name: Repository check + working-directory: /tmp + run: | + [[ ${{ github.repository }} != "prowler-cloud/prowler" ]] && echo "This action only runs for prowler-cloud/prowler"; exit 1 + - name: Get Prowler version run: | PROWLER_VERSION="${{ env.RELEASE_TAG }}"