-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: automated deploy check by changes
- Loading branch information
Showing
4 changed files
with
246 additions
and
152 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,61 +1,83 @@ | ||
name: '[API-HML] Deploy to Amazon ECS' | ||
name: "[API-HML] Deploy to Amazon ECS" | ||
|
||
on: | ||
push: | ||
branches: [ homologacao ] | ||
branches: [homologacao] | ||
|
||
jobs: | ||
check-changes: | ||
name: "[VERIFY] Check for Changes" | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
should_deploy: ${{ steps.check.outputs.should_deploy }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Check for changes in ./packages/api | ||
id: check | ||
run: | | ||
if git diff --quiet HEAD~1 -- ./packages/api; then | ||
echo "No changes detected in ./packages/api" | ||
echo "::set-output name=should_deploy::false" | ||
else | ||
echo "Changes detected in ./packages/api" | ||
echo "::set-output name=should_deploy::true" | ||
fi | ||
deploy: | ||
name: '[API-HMG] Deploy to Amazon ECS' | ||
name: "[API-HMG] Deploy to Amazon ECS" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.BAKO_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.BAKO_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
|
||
- name: Login to Amazon ECR | ||
id: login_ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login_ecr.outputs.registry }} | ||
ECR_REPOSITORY: bako-safe-api-hmg | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
# Build a docker container and push it to ECR | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./packages/api | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task-def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: ./packages/api/hml_api_task_definition.json | ||
container-name: bako-safe-api-hmg | ||
image: ${{ steps.build-image.outputs.image }} | ||
|
||
- name: Deploy Amazon ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
service: bako-safe-api-hmg-service | ||
cluster: Bako-Safe-Hmg | ||
wait-for-service-stability: true | ||
|
||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.BAKO_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.BAKO_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
|
||
- name: Login to Amazon ECR | ||
id: login_ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login_ecr.outputs.registry }} | ||
ECR_REPOSITORY: bako-safe-api-hmg | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
# Build a docker container and push it to ECR | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./packages/api | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task-def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: ./packages/api/hml_api_task_definition.json | ||
container-name: bako-safe-api-hmg | ||
image: ${{ steps.build-image.outputs.image }} | ||
|
||
- name: Deploy Amazon ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
service: bako-safe-api-hmg-service | ||
cluster: Bako-Safe-Hmg | ||
wait-for-service-stability: true |
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 |
---|---|---|
@@ -1,59 +1,83 @@ | ||
name: '[API] Deploy to Amazon ECS' | ||
name: "[API] Deploy to Amazon ECS" | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
branches: [main] | ||
|
||
jobs: | ||
check-changes: | ||
name: "[VERIFY] Check for Changes" | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
should_deploy: ${{ steps.check.outputs.should_deploy }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
with: | ||
fetch-depth: 2 | ||
|
||
- name: Check for changes in ./packages/api | ||
id: check | ||
run: | | ||
if git diff --quiet HEAD~1 -- ./packages/api; then | ||
echo "No changes detected in ./packages/api" | ||
echo "::set-output name=should_deploy::false" | ||
else | ||
echo "Changes detected in ./packages/api" | ||
echo "::set-output name=should_deploy::true" | ||
fi | ||
deploy: | ||
name: '[API] Deploy to Amazon ECS' | ||
name: "[API] Deploy to Amazon ECS" | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.BAKO_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.BAKO_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
|
||
- name: Login to Amazon ECR | ||
id: login_ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login_ecr.outputs.registry }} | ||
ECR_REPOSITORY: bako-safe-api | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
# Build a docker container and push it to ECR | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./packages/api | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task-def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: ./packages/api/prod_api_task_definition.json | ||
container-name: bako-safe-api | ||
image: ${{ steps.build-image.outputs.image }} | ||
|
||
- name: Deploy Amazon ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
service: bako-safe-api-service | ||
cluster: Bako-Safe-ECS | ||
wait-for-service-stability: true | ||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up QEMU | ||
uses: docker/setup-qemu-action@v2 | ||
|
||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v2 | ||
|
||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1 | ||
with: | ||
aws-access-key-id: ${{ secrets.BAKO_AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ secrets.BAKO_AWS_SECRET_ACCESS_KEY }} | ||
aws-region: us-east-1 | ||
|
||
- name: Login to Amazon ECR | ||
id: login_ecr | ||
uses: aws-actions/amazon-ecr-login@v1 | ||
|
||
- name: Build, tag, and push image to Amazon ECR | ||
id: build-image | ||
env: | ||
ECR_REGISTRY: ${{ steps.login_ecr.outputs.registry }} | ||
ECR_REPOSITORY: bako-safe-api | ||
IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
# Build a docker container and push it to ECR | ||
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG ./packages/api | ||
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG | ||
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" | ||
- name: Fill in the new image ID in the Amazon ECS task definition | ||
id: task-def | ||
uses: aws-actions/amazon-ecs-render-task-definition@v1 | ||
with: | ||
task-definition: ./packages/api/prod_api_task_definition.json | ||
container-name: bako-safe-api | ||
image: ${{ steps.build-image.outputs.image }} | ||
|
||
- name: Deploy Amazon ECS task definition | ||
uses: aws-actions/amazon-ecs-deploy-task-definition@v1 | ||
with: | ||
task-definition: ${{ steps.task-def.outputs.task-definition }} | ||
service: bako-safe-api-service | ||
cluster: Bako-Safe-ECS | ||
wait-for-service-stability: true |
Oops, something went wrong.