From 38a979aecfebbcce28c5583f5ad354954c4a49b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9o=20Vincent?= <28714795+leovct@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:46:35 +0200 Subject: [PATCH] ci: log in to the docker hub when possible (#312) * ci: docker hub login * test * fix: docker secrets issues * fix: security build * chore: disable steps if secrets are not defined * chore: clean up * chore: merge latest changes --- .github/workflows/deploy.yml | 60 ++++++++++++++++++++++++++++ .github/workflows/nightly.yml | 18 ++++++++- .github/workflows/security-build.yml | 6 ++- 3 files changed, 82 insertions(+), 2 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index b4c6bbd1c..e5e8491e7 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -22,6 +22,18 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # This step will only execute if the necessary secrets are available, preventing failures + # on pull requests from forked repositories. + if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install Kurtosis CDK tools uses: ./.github/actions/setup-kurtosis-cdk @@ -81,6 +93,18 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # This step will only execute if the necessary secrets are available, preventing failures + # on pull requests from forked repositories. + if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install Kurtosis CDK tools uses: ./.github/actions/setup-kurtosis-cdk @@ -149,6 +173,18 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # This step will only execute if the necessary secrets are available, preventing failures + # on pull requests from forked repositories. + if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install Kurtosis CDK tools uses: ./.github/actions/setup-kurtosis-cdk @@ -240,6 +276,18 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # This step will only execute if the necessary secrets are available, preventing failures + # on pull requests from forked repositories. + if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install Kurtosis CDK tools uses: ./.github/actions/setup-kurtosis-cdk @@ -297,6 +345,18 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # This step will only execute if the necessary secrets are available, preventing failures + # on pull requests from forked repositories. + if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install Kurtosis CDK tools uses: ./.github/actions/setup-kurtosis-cdk diff --git a/.github/workflows/nightly.yml b/.github/workflows/nightly.yml index 84502fdc1..eda80c3ac 100644 --- a/.github/workflows/nightly.yml +++ b/.github/workflows/nightly.yml @@ -16,12 +16,23 @@ env: jobs: # Deploy a standalone zkevm permisionless node against Cardona Sepolia Tesnet. cardona-sepolia-testnet-pless-zkevm-node: - #if: github.repository == '0xPolygon/kurtosis-cdk' # Prevent this job to run on forks. runs-on: ubuntu-latest timeout-minutes: 20 steps: - uses: actions/checkout@v4 + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + # This step will only execute if the necessary secrets are available, preventing failures + # on pull requests from forked repositories. + if: ${{ env.DOCKERHUB_USERNAME && env.DOCKERHUB_TOKEN }} + env: + DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} + DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }} + - name: Install Kurtosis CDK tools uses: ./.github/actions/setup-kurtosis-cdk @@ -29,6 +40,11 @@ jobs: run: | yq -Y --in-place '.args.l1_rpc_url = "${{ secrets.ALCHEMY_SEPOLIA_RPC_URL }}"' ./.github/tests/pless-zkevm-node/cardona-sepolia-testnet-pless-zkevm-node.yml kurtosis run --enclave=${{ env.ENCLAVE_NAME }} --args-file=./.github/tests/pless-zkevm-node/cardona-sepolia-testnet-pless-zkevm-node.yml --show-enclave-inspect=false . + # This step will only execute if the necessary secrets are available, preventing failures + # on pull requests from forked repositories. + if: ${{ env.ALCHEMY_SEPOLIA_RPC_URL}} + env: + ALCHEMY_SEPOLIA_RPC_URL: ${{ secrets.ALCHEMY_SEPOLIA_RPC_URL }} - name: Inspect enclave run: kurtosis enclave inspect ${{ env.ENCLAVE_NAME }} diff --git a/.github/workflows/security-build.yml b/.github/workflows/security-build.yml index 0a9c8298c..7edc52509 100644 --- a/.github/workflows/security-build.yml +++ b/.github/workflows/security-build.yml @@ -10,7 +10,6 @@ jobs: sonarcloud: runs-on: ubuntu-latest timeout-minutes: 5 - if: github.repository == '0xPolygon/kurtosis-cdk' # Prevent this job to run on forks. steps: - uses: actions/checkout@v4 with: @@ -21,3 +20,8 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + # This step will only execute if the necessary secrets are available, preventing failures + # on pull requests from forked repositories. + if: ${{ env.SONAR_TOKEN}} + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}