Skip to content

배포 과정 환경변수 오류 설정. #2

배포 과정 환경변수 오류 설정.

배포 과정 환경변수 오류 설정. #2

Workflow file for this run

name: SpringBoot deploy with Docker
on:
# after merge to main with pr
pull_request:
types: [ closed ]
branches: [ "develop" ]
jobs:
build-and-deploy:
runs-on: ubuntu-22.04
permissions:
contents: read
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
- name: Build with Gradle Wrapper
run: ./gradlew build -x test
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and Push Docker Image
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }} .
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }}
- name: Modify docker-compose.dev.yaml
run: |
sed -i "s|REPLACE_IMAGE_TAG|${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKER_REPOSITORY }}:${{ github.sha }}|g" docker-compose.dev.yaml &&
sed -i "s|REPLACE_GOOGLE_CLIENT_ID|${{ secrets.GOOGLE_CLIENT_ID }}|g" docker-compose.dev.yaml &&
sed -i "s|REPLACE_GOOGLE_CLIENT_SECRET|${{ secrets.GOOGLE_CLIENT_SECRET }}|g" docker-compose.dev.yaml &&
sed -i "s|REPLACE_GOOGLE_REDIRECT_URI|${{ secrets.GOOGLE_REDIRECT_URI }}|g" docker-compose.dev.yaml &&
sed -i "s|REPLACE_JWT_SECRET|${{ secrets.JWT_SECRET }}|g" docker-compose.dev.yaml
- name: Send script to remote server
uses: appleboy/scp-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
source: "docker-compose.dev.yaml,script/deploy.sh"
target: /home/${{ secrets.REMOTE_USERNAME }}/gdsc-project
- name: SSH to remote server and run docker-compose
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.REMOTE_HOST }}
username: ${{ secrets.REMOTE_USERNAME }}
key: ${{ secrets.SSH_PRIVATE_KEY }}
script: |
cd /home/${{ secrets.REMOTE_USERNAME }}/gdsc-project/script
chmod +x deploy.sh
sudo ./deploy.sh
dependency-submission:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
# See: https://github.com/gradle/actions/blob/main/dependency-submission/README.md
- name: Generate and submit dependency graph
uses: gradle/actions/dependency-submission@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0