HelloWorld #11
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
name: GG GoLab server CI/CD | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
env: | |
S3_BUCKET_NAME: golabgolab | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v2 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
run: ./gradlew clean build | |
# 디렉토리 생성 | |
- name: Make Directory | |
run: mkdir -p deploy | |
# Jar 파일 복사 | |
- name: Copy Jar | |
run: cp ./build/libs/*.jar ./deploy | |
# appspec.yml 파일 복사 | |
- name: Copy appspec.yml | |
run: cp appspec.yml ./deploy | |
# script files 복사 | |
- name: Copy script | |
run: cp ./scripts/*.sh ./deploy | |
- name: Make zip file | |
run: zip -r ./golab.zip ./deploy | |
shell: bash | |
- name: Configure 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: ap-northeast-2 | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./golab.zip s3://$S3_BUCKET_NAME/ | |
# Deploy | |
- name: Deploy | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
run: | | |
aws deploy create-deployment \ | |
--application-name golab \ | |
--deployment-group-name golab-group \ | |
--file-exists-behavior OVERWRITE \ | |
--s3-location bucket=golabgolab,bundleType=zip,key=golab.zip \ | |
--region ap-northeast-2 |