TWTW Backend CD #6
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: TWTW Backend CD | |
on: | |
workflow_run: | |
workflows: ["TWTW Backend CI"] | |
types: | |
- completed | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Set environment variables | |
run: | | |
echo "MYSQL_HOST=${{ secrets.MYSQL_HOST }}" >> $GITHUB_ENV | |
echo "MYSQL_PORT=${{ secrets.MYSQL_PORT }}" >> $GITHUB_ENV | |
echo "MYSQL_DATABASE=${{ secrets.MYSQL_DATABASE }}" >> $GITHUB_ENV | |
echo "MYSQL_USER=${{ secrets.MYSQL_USER }}" >> $GITHUB_ENV | |
echo "MYSQL_PASSWORD=${{ secrets.MYSQL_PASSWORD }}" >> $GITHUB_ENV | |
echo "RABBITMQ_USERNAME=${{ secrets.RABBITMQ_USERNAME }}" >> $GITHUB_ENV | |
echo "RABBITMQ_PASSWORD=${{ secrets.RABBITMQ_PASSWORD }}" >> $GITHUB_ENV | |
echo "JWT_SECRET=${{ secrets.JWT_SECRET }}" >> $GITHUB_ENV | |
echo "KAKAO_MAP_URL=${{ secrets.KAKAO_MAP_URL }}" >> $GITHUB_ENV | |
echo "KAKAO_MAP_KEY=${{ secrets.KAKAO_MAP_KEY }}" >> $GITHUB_ENV | |
echo "KAKAO_MAP_HEADER=${{ secrets.KAKAO_MAP_HEADER }}" >> $GITHUB_ENV | |
echo "NAVER_MAP_ID=${{ secrets.NAVER_MAP_ID }}" >> $GITHUB_ENV | |
echo "NAVER_MAP_SECRET=${{ secrets.NAVER_MAP_SECRET }}" >> $GITHUB_ENV | |
echo "NAVER_MAP_URL=${{ secrets.NAVER_MAP_URL }}" >> $GITHUB_ENV | |
echo "NAVER_MAP_HEADER_ID=${{ secrets.NAVER_MAP_HEADER_ID }}" >> $GITHUB_ENV | |
echo "NAVER_MAP_HEADER_SECRET=${{ secrets.NAVER_MAP_HEADER_SECRET }}" >> $GITHUB_ENV | |
echo "TMAP_KEY=${{ secrets.TMAP_KEY }}" >> $GITHUB_ENV | |
echo "TMAP_URL=${{ secrets.TMAP_URL }}" >> $GITHUB_ENV | |
- name: Grant execute permission for gradlew | |
run: chmod +x ./backend/gradlew | |
shell: bash | |
- name: Build with jib | |
run: | | |
cd ./backend | |
./gradlew jib \ | |
-Djib.to.auth.username=${{ secrets.DOCKER_USERNAME }} \ | |
-Djib.to.auth.password=${{ secrets.DOCKER_PASSWORD }} | |
cd .. | |
- name: Set up Google Cloud SDK | |
uses: google-github-actions/[email protected] | |
with: | |
version: '455.0.0' | |
project_id: ${{ secrets.GCP_PROJECT }} | |
service_account_key: ${{ secrets.GCP_KEY }} | |
export_default_credentials: true | |
- name: Deploy to GCE with Docker Compose | |
run: | | |
gcloud compute scp docker-compose.yml instance-name:~/twtw-server --zone=${{ secrets.GCP_ZONE }} | |
gcloud compute ssh instance-name --command="docker-compose up --build -d" |