Skip to content
This repository has been archived by the owner on Aug 26, 2024. It is now read-only.

chore: using ecs

chore: using ecs #12

Workflow file for this run

name: CI/CD Pipeline
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
env:
ECR_CLUSTER: ${{ secrets.ECR_CLUSTER }}
ECR_SERVICE: ${{ secrets.ECR_SERVICE }}
steps:
- name: Checkout code
uses: actions/checkout@v2
with:
persist-credentials: false
- name: Set up JDK 17
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Build with Gradle
run: ./gradlew build
- name: Configure AWS credentials
id: 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: ${{ secrets.AWS_REGION }}
- name: Login to Amazon ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: Build, tag, and push image to Amazon ECR
id: build-image
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
echo "::set-output name=image::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG"
# - name: Deploy to App Runner Image
# id: deploy-apprunner
# uses: awslabs/amazon-app-runner-deploy@main
# with:
# service: app-runner-git-deploy-service
# image: ${{ steps.build-image.outputs.image }}
# access-role-arn: ${{ secrets.ROLE_ARN }}
# region: ${{ secrets.AWS_REGION }}
# cpu: 1
# memory: 2
# wait-for-service-stability-seconds: 1200
#
# - name: App Runner URL
# run: echo "App runner URL ${{ steps.deploy-apprunner.outputs.service-url }}"
- name: Update image in AWS
run: |
aws ecs update-service --cluster $ECR_CLUSTER --service $ECR_SERVICE --force-new-deployment