π: bugfix CodeDeploy Script at specified location: run_new_was.sh faiβ¦ #3
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: API Server Java CD with Gradle on DEV | |
# develop λΈλμΉμ push μμ λμ | |
on: | |
push: | |
branches: [ "develop" ] | |
env: | |
S3_BUCKET_NAME: codere-s3 | |
jobs: | |
build: | |
name: Code deployment | |
# μ€ν νκ²½ | |
runs-on: ubuntu-latest | |
steps: | |
# 1) μν¬νλ‘μ° μ€ν μ κΈ°λ³Έμ μΌλ‘ 체ν¬μμ νμ | |
- name: checkout | |
uses: actions/checkout@v3 | |
# 2) JDK 11λ²μ μ€μΉ, λ€λ₯Έ JDK λ²μ μ μ¬μ©νλ€λ©΄ μμ | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'corretto' | |
# 3) application.yml μΈν | |
- name: setting application.yml | |
run: | | |
cd ./src/main/resources # resources ν΄λλ‘ μ΄λ | |
echo "${{ secrets.APPLICATION_YML }}" > ./application.yml | |
echo "${{ secrets.APPLICATION_DEV_YML }}" > ./application-dev.yml | |
shell: bash | |
# 4) build | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle # μ€μ application build(-x μ΅μ μ ν΅ν΄ ν μ€νΈλ μ μΈ) | |
run: ./gradlew clean build -x test | |
# 5) λ°°ν¬ νμΌμ λ΄μ λλ ν 리 μμ± | |
- name: Make Directory | |
run: mkdir -p deploy | |
# 6) Jar νμΌ λ³΅μ¬ | |
- name: Copy Jar | |
run: cp ./build/libs/*.jar ./deploy | |
# 7) appspec.yml, script files λ³΅μ¬ | |
- name: Copy files | |
run: cp ./scripts/* ./deploy | |
# 8) λ°°ν¬ μμΆ νμΌ μμ± | |
- name: Make zip file | |
run: zip -r ./core.zip ./deploy | |
shell: bash | |
# 9) S3μ λ°°ν¬ μμΆ νμΌ μ λ‘λ | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_DEV }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_KEY_DEV }} | |
aws-region: ap-northeast-2 | |
- name: Upload to S3 | |
run: aws s3 cp --region ap-northeast-2 ./core.zip s3://$S3_BUCKET_NAME/ | |
# Deploy | |
- name: Deploy | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_DEV }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_KEY_DEV }} | |
run: | |
aws deploy create-deployment | |
--application-name core-codeDeploy | |
--deployment-group-name API_SERVER | |
--file-exists-behavior OVERWRITE | |
--s3-location bucket=$S3_BUCKET_NAME,bundleType=zip,key=core.zip | |
--region ap-northeast-2 | |