Skip to content

Cicd/part2

Cicd/part2 #7

Workflow file for this run

name: robot CI with Gradle
on:
push:
branches: [ "master" ]
paths:
- 'robot-service/**'
pull_request:
branches: [ "master" ]
paths:
- 'robot-service/**'
permissions:
contents: read
jobs:
deploy-service-1:
runs-on: ubuntu-latest
env:
working-directory: ./robot-service
service-name: robot-service
steps:
- name: Checkout repository
uses: actions/checkout@v2
# 2) JDK 11 버전 설치, 다른 JDK 버전을 사용한다면 수정 필요
- name: Set up JDK 11
uses: actions/setup-java@v3
with:
java-version: '11'
distribution: 'temurin'
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
working-directory: ${{ env.working-directory }}
- name: Build with Gradle
run: ./gradlew init; ./gradlew build --exclude-task test
working-directory: ${{ env.working-directory }}
- name: Copy Jar
run: cp ./build/libs/*.jar ./deploy
working-directory: ${{ env.working-directory }}
- name: Make zip file
run:
zip -j ./${{ env.service-name }}.zip ./deploy/run_java.sh ./deploy/kill_process.sh ./deploy/appspec.yml ./deploy/*.jar ./deploy/Dockerfile
working-directory: ${{ env.working-directory }}
- name: Awsaccess
uses: aws-actions/configure-aws-credentials@v1
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Upload to S3
run: aws s3 cp --region ${{ secrets.AWS_REGION }} ${{ env.working-directory }}/${{ env.service-name }}.zip s3://${{ secrets.S3_BUCKET_NAME }}/${{ env.service-name }}.zip
- name: Code Deploy
run: aws deploy create-deployment
--application-name ${{ secrets.CODEDEPLOY_NAME }}
--deployment-config-name CodeDeployDefault.AllAtOnce
--deployment-group-name ${{ secrets.CODEDEPLOY_GROUP }}
--s3-location bucket=${{ secrets.S3_BUCKET_NAME }},bundleType=zip,key=${{ env.service-name }}.zip