Merge pull request #241 from 100-hours-a-week/develop #19
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: BE Production Build & Deploy | |
on: | |
push: | |
branches: | |
# master 브랜치로 merge되어 push가 트리거 된 경우 실행 | |
- master | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./gradlew | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'corretto' | |
java-version: '17' | |
- name: Build with Gradle | |
env: | |
PROD_SENTRY_AUTH_TOKEN: ${{ secrets.PROD_SENTRY_AUTH_TOKEN }} | |
PROD_SENTRY_DSN: ${{ secrets.PROD_SENTRY_DSN }} | |
run: ./gradlew bootJar | |
- name: Build Docker Image | |
run: | | |
docker build \ | |
--build-arg PROD_SENTRY_DSN=${{ secrets.PROD_SENTRY_DSN }} \ | |
--build-arg PROD_SENTRY_AUTH_TOKEN=${{ secrets.PROD_SENTRY_AUTH_TOKEN }} \ | |
-t ghcr.io/topazkang/be-prod:latest . | |
- name: Log in to GitHub Container Registry | |
run: echo "${{ secrets.GHCR_TOKEN }}" | docker login ghcr.io -u ${{ secrets.GIT_USER }} --password-stdin | |
- name: Push Docker Image to GHCR | |
run: docker push ghcr.io/topazkang/be-prod:latest | |
deploy: | |
runs-on: [ self-hosted, Linux, X64, connectrip_be_prod ] | |
name: Deploy on Self-Hosted Runner | |
needs: build | |
steps: | |
- name: set env & deploy | |
run: | | |
cd /home/ubuntu/deploy/back | |
echo "${{ secrets.ENV_FILE_PROD }}" > .env | |
sudo sh switch.sh |