Merge pull request #77 from delicious-algorithme/fix/73-login-nicknam… #9
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: Matal Backend CI/CD with Gradle Cache | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
submodules: recursive | |
ssh-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Set up SSH | |
uses: webfactory/[email protected] | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v4 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: gradle | |
- name: Setup Gradle | |
uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0 | |
- name: Cache Gradle dependencies | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: gradle-${{ runner.os }}-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}-${{ env.GRADLE_VERSION }} | |
restore-keys: | | |
gradle-${{ runner.os }}- | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
- name: Build with Gradle Wrapper | |
run: ./gradlew clean build | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v2 | |
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: Zip the JAR file | |
run: | | |
zip -r myapp.zip build/libs/*.jar appspec.yml scripts \ | |
src/main/resources/logback-spring.xml \ | |
src/main/resources/warn-appender.xml \ | |
src/main/resources/error-appender.xml \ | |
src/main/resources/info-appender.xml | |
- name: Upload the ZIP file to S3 | |
run: aws s3 cp myapp.zip s3://matal-s3/ | |
- name: Deploy to CodeDeploy | |
run: | | |
aws deploy create-deployment \ | |
--application-name matal-codedeploy \ | |
--deployment-group-name matal-BE-codedeploy \ | |
--deployment-config-name CodeDeployDefault.OneAtATime \ | |
--description "Deploying from GitHub Actions" \ | |
--file-exists-behavior OVERWRITE \ | |
--s3-location bucket=matal-s3,key=myapp.zip,bundleType=zip |