-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bffc284
commit 85a1e93
Showing
6 changed files
with
362 additions
and
47 deletions.
There are no files selected for viewing
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
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
File renamed without changes.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
name: Application CI/CD | ||
|
||
on: | ||
push: | ||
branches: [ "master" ] | ||
|
||
jobs: | ||
tests-n-cs: | ||
uses: ./.github/workflows/tests-n-cs.yml | ||
|
||
docker-image-ecr: | ||
runs-on: ubuntu-latest | ||
needs: tests-n-cs | ||
|
||
steps: | ||
- name: Check out the repository | ||
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: ${{ vars.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
run: | | ||
aws ecr get-login-password --region ${{ vars.AWS_REGION }} \ | ||
| docker login --username AWS --password-stdin ${{ secrets.ECR_REPOSITORY_URI }} | ||
- name: Build Docker image (Octane) | ||
run: docker build . --file Dockerfile.app --tag ${{ vars.DOCKER_IMAGE_TAG }}/octane | ||
|
||
- name: Build Docker image (Nginx) | ||
run: docker build . --file Dockerfile.nginx --tag ${{ vars.DOCKER_IMAGE_TAG }}/nginx | ||
|
||
- name: Tag Docker images | ||
run: | | ||
docker tag ${{ vars.DOCKER_IMAGE_TAG }}/octane:latest ${{ secrets.ECR_REPOSITORY_URI }}:latest-octane | ||
docker tag ${{ vars.DOCKER_IMAGE_TAG }}/nginx:latest ${{ secrets.ECR_REPOSITORY_URI }}:latest-nginx | ||
- name: Push Docker images to ECR | ||
run: | | ||
docker push ${{ secrets.ECR_REPOSITORY_URI }}:latest-octane | ||
docker push ${{ secrets.ECR_REPOSITORY_URI }}:latest-nginx | ||
ecs-service-deploy: | ||
runs-on: ubuntu-latest | ||
needs: docker-image-ecr | ||
|
||
steps: | ||
- name: Check out the repository | ||
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: ${{ vars.AWS_REGION }} | ||
|
||
- name: Update ECS task definition | ||
run: | | ||
sed -i 's|<ECS_TASK_EXEC_ROLE>|${{ secrets.ECS_TASK_EXEC_ROLE }}|' ./aws/ecs/deployment-task.json | ||
sed -i 's|<ECS_TASK_ROLE>|${{ secrets.ECS_TASK_ROLE }}|' ./aws/ecs/deployment-task.json | ||
sed -i 's|<ECS_SERVICE_NAME>|${{ vars.ECS_SERVICE_NAME }}|' ./aws/ecs/deployment-task.json | ||
sed -i 's|<SSM_NAMESPACE>|${{ secrets.SSM_NAMESPACE }}|' ./aws/ecs/deployment-task.json | ||
sed -i 's|<IMAGE_OCTANE>|${{ secrets.ECR_REPOSITORY_URI }}:latest-octane|' ./aws/ecs/deployment-task.json | ||
sed -i 's|<IMAGE_NGINX>|${{ secrets.ECR_REPOSITORY_URI }}:latest-nginx|' ./aws/ecs/deployment-task.json | ||
- name: Register updated task definition | ||
run: | | ||
aws ecs register-task-definition \ | ||
--cli-input-json file://./aws/ecs/deployment-task.json \ | ||
--region ${{ vars.AWS_REGION }} | ||
- name: Deploy updated ECS service | ||
run: | | ||
aws ecs update-service \ | ||
--cluster ${{ vars.ECS_CLUSTER }} \ | ||
--service ${{ vars.ECS_SERVICE_NAME }} \ | ||
--task-definition ${{ vars.ECS_SERVICE_NAME }}-task \ | ||
--force-new-deployment \ | ||
--region ${{ vars.AWS_REGION }} |
Oops, something went wrong.