Load credentials #4
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: deploy | |
on: | |
push | |
jobs: | |
build: | |
name: Build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v2 | |
# - name: Update deployment status (in_progress) | |
# uses: chrnorm/deployment-status@releases/v1 | |
# with: | |
# token: "${{ github.token }}" | |
# state: "in_progress" | |
# deployment_id: ${{ github.event.deployment.id }} | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: us-east-1 | |
- name: Build the Docker container | |
shell: bash | |
run: | | |
export GIT_TAG=$(echo $GITHUB_SHA | head -c 7) | |
docker build --build-arg GIT_TAG -t dk-sample-backend:latest . | |
- name: AWS ECR Log In | |
run: | | |
$(aws ecr get-login --registry-ids 568023081912 --no-include-email --region us-east-1) | |
- name: Push the Docker container | |
shell: bash | |
run: | | |
export GIT_TAG=$(echo $GITHUB_SHA | head -c 7) | |
docker tag dk-sample-backend:latest 568023081912.dkr.ecr.us-east-1.amazonaws.com/dk-sample-backend:$GIT_TAG | |
docker tag dk-sample-backend:latest 568023081912.dkr.ecr.us-east-1.amazonaws.com/dk-sample-backend:$TARGET_ENV | |
docker push 568023081912.dkr.ecr.us-east-1.amazonaws.com/dk-sample-backend:$GIT_TAG | |
docker push 568023081912.dkr.ecr.us-east-1.amazonaws.com/dk-sample-backend:$TARGET_ENV | |
- name: Cleanup the containers | |
shell: bash | |
run: | | |
export GIT_TAG=$(echo $GITHUB_SHA | head -c 7) | |
docker rmi -f dk-sample-backend:latest 568023081912.dkr.ecr.us-east-1.amazonaws.com/dk-sample-backend:$TARGET_ENV 568023081912.dkr.ecr.us-east-1.amazonaws.com/dk-sample-backend:$GIT_TAG | |
# - name: Update deployment status (failure) | |
# if: failure() | |
# uses: chrnorm/deployment-status@releases/v1 | |
# with: | |
# token: "${{ github.token }}" | |
# state: "failure" | |
# deployment_id: ${{ github.event.deployment.id }} | |
deploy: | |
needs: build | |
name: Deploy | |
runs-on: ${{ github.event.deployment.environment }} | |
steps: | |
- name: Checkout the repository | |
uses: actions/checkout@v2 | |
- name: Trigger ECS deployment | |
run: | | |
aws --region us-east-1 ecs update-service --cluster dk-sample-$TARGET_ENV --service dk-sample-backend-$TARGET_ENV --force-new-deployment | |
# - name: Update deployment status (success) | |
# if: success() | |
# uses: chrnorm/deployment-status@releases/v1 | |
# with: | |
# token: "${{ github.token }}" | |
# state: "success" | |
# deployment_id: ${{ github.event.deployment.id }} | |
# - name: Update deployment status (failure) | |
# if: failure() | |
# uses: chrnorm/deployment-status@releases/v1 | |
# with: | |
# token: "${{ github.token }}" | |
# state: "failure" | |
# deployment_id: ${{ github.event.deployment.id }} |