Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
sm47916 committed Dec 6, 2023
1 parent c0f6d73 commit cd47438
Showing 1 changed file with 29 additions and 20 deletions.
49 changes: 29 additions & 20 deletions .github/workflows/docker_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

0 comments on commit cd47438

Please sign in to comment.