From d3af9475539861c1d97702270fe3e93ec779c573 Mon Sep 17 00:00:00 2001 From: Pepe Fagoaga Date: Thu, 19 Dec 2024 14:19:41 +0545 Subject: [PATCH] fix(gha): make conditional job for checking the repo (#6255) --- .../api-build-lint-push-containers.yml | 25 +++++++++++++++---- .github/workflows/sdk-pypi-release.yml | 25 +++++++++++++++++++ .../ui-build-lint-push-containers.yml | 25 +++++++++++++++---- 3 files changed, 65 insertions(+), 10 deletions(-) diff --git a/.github/workflows/api-build-lint-push-containers.yml b/.github/workflows/api-build-lint-push-containers.yml index 0951f22eca4..5aaec3c4550 100644 --- a/.github/workflows/api-build-lint-push-containers.yml +++ b/.github/workflows/api-build-lint-push-containers.yml @@ -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 0 - - name: Checkout uses: actions/checkout@v4 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 }}" diff --git a/.github/workflows/ui-build-lint-push-containers.yml b/.github/workflows/ui-build-lint-push-containers.yml index 41c0a11017c..23686363977 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 "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 0 - - name: Checkout uses: actions/checkout@v4