Skip to content

Quickfix

Quickfix #7

Workflow file for this run

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-password --region us-east-1 | docker login --username AWS --password-stdin 400869475597.dkr.ecr.us-east-1.amazonaws.com/dk-sample-backend
- name: Push the Docker container
shell: bash
run: |
export GIT_TAG=$(echo $GITHUB_SHA | head -c 7)
docker tag dk-sample-backend:latest 400869475597.dkr.ecr.us-east-1.amazonaws.com/dk-sample-backend:$GIT_TAG
docker tag dk-sample-backend:latest 400869475597.dkr.ecr.us-east-1.amazonaws.com/dk-sample-backend:$TARGET_ENV
docker push 400869475597.dkr.ecr.us-east-1.amazonaws.com/dk-sample-backend:$GIT_TAG
docker push 400869475597.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 400869475597.dkr.ecr.us-east-1.amazonaws.com/dk-sample-backend:$TARGET_ENV 400869475597.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 }}