Skip to content

Merge remote-tracking branch 'origin/main' #10

Merge remote-tracking branch 'origin/main'

Merge remote-tracking branch 'origin/main' #10

Workflow file for this run

name: Chalkac deploy
on:
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Github Repository checkout
uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/[email protected]
with:
java-version: '17'
distribution: 'temurin'
- name: Create resource
run: mkdir -p ./src/main/resources
- name: Create application.properties
run: echo "${{ secrets.APPLICATION_PROPERTIES }}" > ./src/main/resources/application.properties
- name: add permission to gradlew
run: chmod +x ./gradlew
- name: AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-region: ap-northeast-2
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
- name: Login to AWS ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
- name: build docker file and setting deploy files
env:
ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
ECR_REPOSITORY: chalkac
IMAGE_TAG: ${{ github.sha }}
run: |
docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
mkdir scripts
touch scripts/deploy.sh
echo "aws ecr get-login-password --region ap-northeast-2 | docker login --username AWS --password-stdin $ECR_REGISTRY" >> scripts/deploy.sh
echo "docker pull $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> scripts/deploy.sh
echo "docker run -p 8080:8080 -e PROFILE=dev -d --restart always --name chalkac $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> scripts/deploy.sh
- name: upload to s3
env:
IMAGE_TAG: ${{ github.sha }}
run: |
echo $IMAGE_TAG > latest_tag.txt
zip -r deploy-$IMAGE_TAG.zip ./scripts appspec.yml
aws s3 cp --region ap-northeast-2 --acl private ./deploy-$IMAGE_TAG.zip s3://chalkac-bucket
aws s3 cp --region ap-northeast-2 --acl private latest_tag.txt s3://chalkac-bucket/latest_tag.txt
- name: start deploy
env:
IMAGE_TAG: ${{ github.sha }}
run: |
aws deploy create-deployment --application-name Chalkac-codedeploy \
--deployment-config-name CodeDeployDefault.OneAtATime \
--deployment-group-name deploy-group \
--s3-location bucket=chalkac-bucket,bundleType=zip,key=deploy-$IMAGE_TAG.zip