Skip to content

Running

Running #65

Workflow file for this run

name: leets-actions
run-name: Running
on:
push:
branches:
- main
- 'releases/**'
env:
AWS_REGION: ap-northeast-2
RESOURCE_PATH: ./src/main/resources/application.yml
jobs:
build-with-gradle:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v3
- name: JDK 17 설치
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: 환경변수 설정
uses: microsoft/variable-substitution@v1
with:
files: ${{ env.RESOURCE_PATH }}
env:
spring.datasource.username: ${{ secrets.DATABASE_USERNAME }}
spring.datasource.url: ${{ secrets.DATABASE_URL }}
spring.datasource.password: ${{ secrets.DATABASE_PASSWORD }}
spring.mail.host: ${{ secrets.MAIL_HOST }}
spring.mail.username: ${{ secrets.MAIL_USERNAME }}
spring.mail.password: ${{ secrets.MAIL_PASSWORD }}
spring.security.oauth2.client.registration.google.client-id: ${{ secrets.GOOGLE_ID }}
spring.security.oauth2.client.registration.google.client-secret: ${{ secrets.GOOGLE_PASSWORD }}
spring.security.oauth2.client.registration.google.redirect-uri: ${{ secrets.GOOGLE_REDIRECT_URL }}
jwt.auth.access_secret: ${{ secrets.JWT_ACCESS_SECRET }}
jwt.auth.refresh_secret: ${{ secrets.JWT_REFRESH_SECRET }}
cors.origin.development: ${{ secrets.CORS_ORIGIN_DEVELOPMENT }}
cors.origin.production: ${{ secrets.CORS_ORIGIN_PRODUCTION }}
google.auth.url: ${{ secrets.GOOGLE_AUTH_URL }}
google.redirect.url: ${{ secrets.GOOGLE_REDIRECT_URL }}
target.url.dev: ${{ secrets.TARGET_URL_DEV }}
target.url.prod: ${{ secrets.TARGET_URL_PROD }}
- name: gradlew에 실행 권한 부여
run: chmod +x ./gradlew
- name: 프로젝트 빌드
run: ./gradlew clean build -x test
- name: DockerHub 로그인
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Docker image Build 및 Push
run: |
docker build -t ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }} .
docker push ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}
- name: EC2에 배포
uses: appleboy/ssh-action@master
id: deploy
with:
host: ${{ secrets.HOST }}
username: ec2-user
key: ${{ secrets.KEY }}
envs: GITHUB_SHA
script: |
sudo docker rm -f $(docker ps -qa)
sudo docker pull ${{ secrets.DOCKER_USERNAME }}/${{ secrets.DOCKER_REPO }}-dev
docker image prune -f