diff --git a/.github/workflows/ci-cd-pipeline.yml b/.github/workflows/ci-cd-pipeline.yml index 9749499dc3..54381f5f7d 100644 --- a/.github/workflows/ci-cd-pipeline.yml +++ b/.github/workflows/ci-cd-pipeline.yml @@ -2,20 +2,28 @@ name: CI/CD on: push: - branches: [main] + branches: [main, wojciechos/cleanup-ci] tags: [v*] jobs: - docker_build_and_publish_amd: + setup: runs-on: ubuntu-latest steps: - - name: Call AMD Build Workflow - id: amd_build - uses: ./.github/workflows/docker-build-publish-amd.yml + - name: Checkout code + uses: actions/checkout@v4 with: - tag: ${{ github.ref }} + fetch-depth: 0 + + - name: Define docker image tag + run: echo "DOCKER_IMAGE_TAG=$(git describe --tags)" >> $GITHUB_ENV outputs: - AMD_IMAGE_TAG: ${{ steps.amd_build.outputs.AMD_IMAGE_TAG }} + DOCKER_IMAGE_TAG: ${{ env.DOCKER_IMAGE_TAG }} + + docker_build_and_publish_amd: + needs: [setup] + uses: ./.github/workflows/docker-build-publish-amd.yml + with: + tag: ${{ needs.setup.outputs.DOCKER_IMAGE_TAG }} deploy_to_dev: needs: [docker_build_and_publish_amd] @@ -26,7 +34,7 @@ jobs: - name: Repository Dispatch Dev env: EVENT_NAME: juno-dev - IMAGE_TAG: ${{ needs.docker_build_and_publish_amd.outputs.AMD_IMAGE_TAG }} + IMAGE_TAG: ${{ needs.setup.outputs.DOCKER_IMAGE_TAG }} GOERLI: apps/juno-dev/overlays/dev-goerli-1/config.yaml INTEGRATION: apps/juno-dev/overlays/dev-integration/config.yaml MAINNET: apps/juno-dev/overlays/dev-mainnet/config.yaml @@ -71,7 +79,7 @@ jobs: - name: Repository Dispatch Staging env: EVENT_NAME: juno-staging - IMAGE_TAG: ${{ needs.docker_build_and_publish_amd.outputs.AMD_IMAGE_TAG }} + IMAGE_TAG: ${{ needs.setup.outputs.DOCKER_IMAGE_TAG }} GOERLI: apps/juno-staging/overlays/staging-goerli-1/config.yaml INTEGRATION: apps/juno-staging/overlays/staging-integration/config.yaml MAINNET: apps/juno-staging/overlays/staging-mainnet/config.yaml @@ -116,7 +124,7 @@ jobs: - name: Repository Dispatch Prod env: EVENT_NAME: juno-prod - IMAGE_TAG: ${{ needs.docker_build_and_publish_amd.outputs.AMD_IMAGE_TAG }} + IMAGE_TAG: ${{ needs.setup.outputs.DOCKER_IMAGE_TAG }} GOERLI: apps/juno-prod/overlays/prod_goerli-1/config.yaml INTEGRATION: apps/juno-prod/overlays/prod_integration/config.yaml MAINNET: apps/juno-prod/overlays/prod_mainnet/config.yaml diff --git a/.github/workflows/docker-build-publish-amd.yml b/.github/workflows/docker-build-publish-amd.yml index fad3403898..684aa61f03 100644 --- a/.github/workflows/docker-build-publish-amd.yml +++ b/.github/workflows/docker-build-publish-amd.yml @@ -2,13 +2,17 @@ name: Docker Build and Publish AMD on: workflow_call: + inputs: + tag: + required: true + type: string jobs: build_and_push_amd: runs-on: ubuntu-latest steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -27,11 +31,4 @@ jobs: context: . platforms: 'linux/amd64' push: true - tags: nethermindeth/juno:${{ github.ref }} - - - name: Set Output - id: set_output - run: echo "AMD_IMAGE_TAG=${{ github.ref }}" >> $GITHUB_ENV - - outputs: - AMD_IMAGE_TAG: ${{ steps.set_output.outputs.AMD_IMAGE_TAG }} + tags: nethermindeth/juno:${{ github.event.inputs.tag }} \ No newline at end of file diff --git a/.github/workflows/docker-build-publish-arm.yml b/.github/workflows/docker-build-publish-arm.yml index 55a5789f34..682bd6bc09 100644 --- a/.github/workflows/docker-build-publish-arm.yml +++ b/.github/workflows/docker-build-publish-arm.yml @@ -2,6 +2,10 @@ name: Docker Build and Publish ARM on: workflow_call: + inputs: + tag: + required: true + type: string jobs: build_and_push_arm: @@ -9,7 +13,7 @@ jobs: runs-on: self-hosted steps: - name: Checkout code - uses: actions/checkout@v3 + uses: actions/checkout@v4 with: fetch-depth: 0 @@ -32,11 +36,4 @@ jobs: - name: Cleanup self-hosted run: | - docker system prune -af - - - name: Set Output - id: set_output - run: echo "ARM_IMAGE_TAG=${{ github.event.inputs.tag }}-arm64" >> $GITHUB_ENV - - outputs: - ARM_IMAGE_TAG: ${{ steps.set_output.outputs.ARM_IMAGE_TAG }} \ No newline at end of file + docker system prune -af \ No newline at end of file diff --git a/.github/workflows/docker-image-build-push.yml b/.github/workflows/docker-image-build-push.yml index 220a03d3b8..e10ccf15ed 100644 --- a/.github/workflows/docker-image-build-push.yml +++ b/.github/workflows/docker-image-build-push.yml @@ -17,16 +17,60 @@ on: jobs: build_and_push_docker_image_amd: + if: github.repository_owner == 'NethermindEth' runs-on: ubuntu-latest steps: - - name: Call AMD Build Workflow - uses: ./.github/workflows/docker-build-publish-amd.yml + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: 'linux/amd64' + push: true + tags: nethermindeth/juno:${{ github.event.inputs.tag }} build_and_push_docker_image_arm: + if: github.repository_owner == 'NethermindEth' runs-on: self-hosted steps: - - name: Call ARM Build Workflow - uses: ./.github/workflows/docker-build-publish-arm.yml + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 + + - name: Login to Docker Hub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD }} + + - name: Build and push ARM + uses: docker/build-push-action@v4 + with: + context: . + platforms: 'linux/arm64' + push: true + tags: nethermindeth/juno:${{ github.event.inputs.tag }}-arm64 + + - name: Cleanup self-hosted + run: | + docker system prune -af create_and_push_official_image: if: github.repository_owner == 'NethermindEth' && github.event.inputs.repo_type == 'official' @@ -51,4 +95,5 @@ jobs: - name: Clean up environment if: always() run: | - rm -f ${HOME}/.docker/config.json \ No newline at end of file + rm -f ${HOME}/.docker/config.json + \ No newline at end of file