cicd: submodule μμ #75
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: Deploy to Production | |
on: | |
push: | |
branches: | |
- develop | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout source code | |
uses: actions/checkout@master | |
with: | |
token: ${{ secrets.ACTION_TOKEN }} | |
submodules: true | |
# - name: Update submodules | |
# run: git submodule update --remote | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'zulu' | |
- name: Gradle Caching | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Build with Gradle | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: ./gradlew build | |
# λ°°ν¬μ νμν μ¬λ¬ μ€μ νμΌκ³Ό νλ‘μ νΈ λΉλ νμΌμ zip νμΌλ‘ λͺ¨μμ€λ€. | |
- name: Make zip file | |
run: | | |
mkdir deploy | |
cp ./docker/docker-compose.blue.yml ./deploy/ | |
cp ./docker/docker-compose.green.yml ./deploy/ | |
cp ./appspec.yml ./deploy/ | |
cp ./scripts/deploy.sh ./deploy/ | |
cp ./Dockerfile ./deploy/ | |
cp ./core/core-api/build/libs/core-api-0.0.1-SNAPSHOT.jar ./deploy/ | |
zip -r -qq -j ./spring-build.zip ./deploy | |
- 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 \ | |
./spring-build.zip s3://melly-s3 | |
# μΆκ° | |
- name: Code Deploy | |
run: aws deploy create-deployment --application-name melly | |
--deployment-config-name CodeDeployDefault.HalfAtATime | |
--deployment-group-name melly-group | |
--s3-location bucket=melly-s3,bundleType=zip,key=spring-build.zip |