diff --git a/.github/workflows/cd.develop.yml b/.github/workflows/cd.develop.yml index 70b6efb..fa2710e 100644 --- a/.github/workflows/cd.develop.yml +++ b/.github/workflows/cd.develop.yml @@ -26,30 +26,13 @@ jobs: - name: Checkout uses: actions/checkout@v2 - - name: Docker meta - id: docker_meta - uses: crazy-max/ghaction-docker-meta@v3 - with: - images: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }} - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - - name: Login to DockerHub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push - uses: docker/build-push-action@v3 - with: - context: . - file: ./dockerfile - platforms: linux/amd64 - push: true - tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest - + - name: Push Image to AWS ECR Public Repo + id: ecr-image-push + run: | + aws ecr-public get-login-password --region ${{ secrets.AWS_REGION }} | docker login --username AWS --password-stdin public.ecr.aws/${{ secrets.AWS_ACCOUNT_ID }} + docker build -t ${{ secrets.ECR_REPOSITORY }}:latest . + docker tag ${{ secrets.ECR_REPOSITORY }}:latest public.ecr.aws/${{ secrets.AWS_ACCOUNT_ID }}/${{ secrets.ECR_REPOSITORY }}:latest + docker push public.ecr.aws/${{ secrets.AWS_ACCOUNT_ID }}/${{ secrets.ECR_REPOSITORY }}:latest deploy: needs: build @@ -66,6 +49,6 @@ jobs: sudo docker rm dev-server sudo docker rm -f $(docker ps -qa) sudo docker image prune -a -f - sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest - sudo docker run --name dev-server --env-file .env -d -p 3000:3000 -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_IMAGE }}:latest + sudo docker pull public.ecr.aws/${{ secrets.AWS_ACCOUNT_ID }}/${{ secrets.ECR_REPOSITORY }}:latest + sudo docker run --name dev-server --env-file .env -d -p 3000:3000 -t public.ecr.aws/${{ secrets.AWS_ACCOUNT_ID }}/${{ secrets.ECR_REPOSITORY }}:latest