Merge pull request #77 from Team-B1ND/Refactor/#76 #117
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: CD | |
on: | |
push: | |
branches: [ "master" ] | |
permissions: | |
contents: read | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Set yml file | |
uses: microsoft/variable-substitution@v1 | |
with: | |
files: dodam-api/src/main/resources/application.yml | |
env: | |
spring.datasource.url: ${{ secrets.DB_URL }} | |
spring.datasource.username: ${{ secrets.DB_USERNAME }} | |
spring.datasource.password: ${{ secrets.DB_PASSWORD }} | |
redis.master.host: ${{ secrets.REDIS_MASTER_HOST }} | |
redis.master.port: ${{ secrets.REDIS_MASTER_PORT }} | |
redis.slaves.0.host: ${{ secrets.REDIS_SLAVE_1_HOST }} | |
redis.slaves.0.port: ${{ secrets.REDIS_SLAVE_1_PORT }} | |
redis.slaves.1.host: ${{ secrets.REDIS_SLAVE_2_HOST }} | |
redis.slaves.1.port: ${{ secrets.REDIS_SLAVE_2_PORT }} | |
app.token.generate: ${{ secrets.TOKEN_GENERATE_URL }} | |
app.token.verify: ${{ secrets.TOKEN_VERIFY_URL }} | |
app.token.refresh: ${{ secrets.TOKEN_REFRESH_URL }} | |
app.jwt.issuer: ${{ secrets.JWT_ISSUER }} | |
app.jwt.tokenServer: ${{ secrets.TOKEN_SERVER_URL }} | |
app.youtube.key.apiKey: ${{ secrets.YOUTUBE_KEY }} | |
app.youtube.url.video: ${{ secrets.YOUTUBE_VIDEO_URL }} | |
app.youtube.url.search: ${{ secrets.YOUTUBE_SEARCH_URL }} | |
app.gabia.id: ${{ secrets.GABIA_ID }} | |
app.gabia.apiKey: ${{ secrets.GABIA_API_KEY }} | |
app.gabia.refKey: ${{ secrets.GABIA_REF_KEY }} | |
app.gabia.tokenUrl: ${{ secrets.GABIA_TOKEN_URL }} | |
app.gabia.smsUrl: ${{ secrets.GABIA_SMS_URL }} | |
app.gabia.lmsUrl: ${{ secrets.GABIA_LMS_URL }} | |
app.gabia.sender: ${{ secrets.GABIA_SMS_SENDER }} | |
app.gabia.subject: ${{ secrets.GABIA_SMS_SUBJECT }} | |
app.neis.apiKey: ${{ secrets.NEIS_KEY }} | |
app.neis.url: ${{ secrets.NEIS_URL }} | |
app.codenary.url: ${{ secrets.CODENARY_URL }} | |
app.melon.url: ${{ secrets.MELON_URL }} | |
app.discord.url: ${{ secrets.DISCORD_URL }} | |
cloud.aws.credentials.access-key: ${{ secrets.S3_ACCESS_KEY }} | |
cloud.aws.credentials.secret-key: ${{ secrets.S3_SECRET_KEY }} | |
cloud.aws.region.static: ${{ secrets.S3_REGION }} | |
cloud.aws.storage.endpoint: ${{ secrets.S3_ENDPOINT }} | |
cloud.aws.storage.bucket: ${{ secrets.S3_BUCKET }} | |
- name: Build with Gradle | |
run: ./gradlew :dodam-api:build -x test --parallel | |
- name: Build Docker Image For Spring | |
run: | | |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }} | |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/dodamdodam:latest . | |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/dodamdodam:latest | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: EC2 Docker Run | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.LINUX_HOST }} | |
username: ${{ secrets.LINUX_USERNAME }} | |
password: ${{ secrets.LINUX_PASSWORD }} | |
port: ${{ secrets.LINUX_SSH_PORT }} | |
script: | | |
docker login -u ${{ secrets.DOCKERHUB_USERNAME }} -p ${{ secrets.DOCKERHUB_PASSWORD }} | |
docker stop dodamdodam | |
docker rm dodamdodam | |
docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/dodamdodam:latest | |
docker pull ${{ secrets.DOCKERHUB_USERNAME }}/dodamdodam:latest | |
docker run -d -p 33333:8080 --name dodamdodam ${{ secrets.DOCKERHUB_USERNAME }}/dodamdodam:latest | |
docker network connect redis-net dodamdodam |