diff --git a/.github/workflows/docker_build.yml b/.github/workflows/docker_build.yml index b63153b..1ac6f70 100644 --- a/.github/workflows/docker_build.yml +++ b/.github/workflows/docker_build.yml @@ -11,8 +11,9 @@ on: name: build and push docker image jobs: - build-and-push: + docker-release: runs-on: ubuntu-latest + if: github.ref == 'refs/heads/master' steps: - uses: actions/checkout@v4 @@ -23,33 +24,41 @@ jobs: aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ${{ secrets.AWS_DEFAULT_REGION }} - - name: Login to Amazon ECR id: login-ecr uses: aws-actions/amazon-ecr-login@v2 + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + platforms: linux/amd64,linux/arm64 + file: docker-builds/Dockerfile + push: true + tags: ${{ secrets.ECR_REGISTRY }}/district0x-landing-page:${{ github.sha }},${{ secrets.ECR_REGISTRY }}/district0x-landing-page:latest + + docker-qa: + runs-on: ubuntu-latest + if: github.ref != 'refs/heads/master' + steps: + - uses: actions/checkout@v4 + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v4 + with: + aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} + aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} + aws-region: ${{ secrets.AWS_DEFAULT_REGION }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v2 - name: Build and push uses: docker/build-push-action@v4 with: context: . platforms: linux/amd64,linux/arm64 - file: docker-builds/${{ matrix.image }}/Dockerfile - build-args: BUILD_ENV=${{ matrix.env }} + file: docker-builds/Dockerfile push: true - tags: ${{ secrets.ECR_REGISTRY }}/ethlance-${{ matrix.image }}:latest-${{ matrix.env }} - - - name: Build push image on commit - env: - ECR_REGISTRY: ${{ secrets.ECR_REGISTRY }} - ECR_REPOSITORY: "district0x-landing-page" - IMAGE_TAG: ${{ github.sha }} - run: | - echo "Building on ${GITHUB_REF} branch" - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f docker-builds/Dockerfile . - if [[ ${GITHUB_REF} == "refs/heads/master" ]]; then - echo "On the default branch will push to the registry with latest and ${IMAGE_TAG} tags" - docker tag $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG $ECR_REGISTRY/$ECR_REPOSITORY:latest - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest - fi + tags: ${{ secrets.ECR_REGISTRY }}/district0x-landing-page:${{ github.sha }},${{ secrets.ECR_REGISTRY }}/district0x-landing-page:qa