Merge pull request #306 from Atractorrr/fix/pinned-count #11
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 Staging | |
on: | |
push: | |
branches: | |
- dev | |
jobs: | |
Deploy: | |
runs-on: ubuntu-latest | |
permissions: | |
deployments: write | |
steps: | |
- name: Github Repository 파일 불러오기 | |
uses: actions/checkout@v4 | |
- name: JDK v21 설치 | |
uses: actions/setup-java@v4 | |
with: | |
distribution: temurin | |
java-version: 21 | |
- name: application-dev.yml 파일 만들기 | |
run: echo '${{ secrets.APPLICATION_DEV_PROPERTIES }}' > ./src/main/resources/application.yml | |
- name: application-test.yml 파일 만들기 | |
run: echo '${{ secrets.APPLICATION_TEST_PROPERTIES }}' > ./src/main/resources/application-test.yml | |
- name: credentials.json 파일 만들기 | |
run: echo '${{ secrets.CREDENTIAL_JSON }}' > ./src/main/resources/credentials.json | |
- name: log4j2.xml 파일 만들기 | |
run: echo '${{ secrets.LOG4J2_XML }}' > ./src/main/resources/log4j2.xml | |
- name: 테스트 및 빌드하기 | |
run: ./gradlew clean build | |
- name: Docker hub 로그인 | |
uses: docker/login-action@v3 | |
with: | |
username: ${{secrets.DOCKERHUB_USERNAME}} | |
password: ${{secrets.DOCKERHUB_TOKEN}} | |
- name: build and release to DockerHub | |
env: | |
NAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
REPO: attraction-api-server | |
run: | | |
docker build -t $REPO . | |
docker tag $REPO:latest $NAME/$REPO:latest | |
docker push $NAME/$REPO:latest | |
- name: 배포 작업 생성 | |
uses: chrnorm/deployment-action@v2 | |
id: deployment | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
environment-url: https://attraction.run | |
environment: dev | |
ref: ${{ github.ref }} | |
- name: SSH로 EC2에 접속하기 | |
uses: appleboy/[email protected] | |
with: | |
host: ${{ secrets.DEV_EC2_HOST }} | |
username: ${{ secrets.DEV_EC2_USERNAME }} | |
key: ${{ secrets.DEV_EC2_PRIVATE_KEY }} | |
script_stop: true | |
script: | | |
cd /home/ec2-user/app | |
wget -O docker-compose.yml https://raw.githubusercontent.com/Atractorrr/Attraction-Server/dev/docker-compose.yml | |
export DOCKERHUB_USERNAME=${{ secrets.DOCKERHUB_USERNAME }} | |
# docker-compose 명령 실행 | |
docker-compose down || true | |
docker-compose pull | |
docker-compose up -d | |
- name: 슬랙 알림 | |
uses: 8398a7/action-slack@v3 | |
with: | |
status: ${{ job.status }} | |
fields: repo,message,commit,author,action,eventName,ref,workflow,job,took,pullRequest | |
env: | |
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} | |
if: always() |