백엔드 배포 작업 (#159) #1
Workflow file for this run
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: All deploy CI + CD on push | ||
on: | ||
push: | ||
branches: [ "deploy" ] | ||
jobs: | ||
deploy-ci-be: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
with: | ||
token: ${{ secrets.SUBMODULE_BE_TOKEN }} | ||
submodules: true | ||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '17' | ||
distribution: 'corretto' | ||
- name: Build with Gradle | ||
uses: gradle/[email protected] | ||
- name: Execute Gradle build | ||
run: | | ||
cd backend/baton | ||
./gradlew build | ||
- name: Setup Docker buildx | ||
uses: docker/[email protected] | ||
- name: Login to Docker Hub | ||
uses: docker/[email protected] | ||
with: | ||
username: ${{ secrets.DOCKERHUB_DEPLOY_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_DEPLOY_TOKEN }} | ||
- name: Docker Image Build | ||
run: | | ||
cd backend/baton | ||
docker build --platform linux/arm64/v8 -t 2023batondeploy/2023-baton-deploy -f Dockerfile-deploy . | ||
- name: Docker Hub Push | ||
run: docker push 2023batondeploy/2023-baton-deploy | ||
deploy-ci-fe: | ||
runs-on: ubuntu-latest | ||
defaults: | ||
run: | ||
working-directory: ./frontend | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
- name: 의존성을 설치한다 | ||
run: npm install | ||
- name: 테스트를 수행한다 | ||
run: npm run test | ||
deploy-cd-be: | ||
needs: deploy-ci-be | ||
runs-on: [self-hosted, Linux, ARM64, deploy] | ||
steps: | ||
- name: Pull Latest Docker Image | ||
run: | | ||
sudo docker login --username ${{ secrets.DOCKERHUB_DEPLOY_USERNAME }} --password ${{ secrets.DOCKERHUB_DEPLOY_TOKEN }} | ||
if sudo docker inspect spring-baton &>/dev/null; then | ||
sudo docker stop spring-baton | ||
sudo docker rm -f spring-baton | ||
sudo docker image prune -af | ||
fi | ||
sudo docker pull 2023batondeploy/2023-baton-deploy:latest | ||
- name: Docker Compose | ||
run: | | ||
sudo docker run --name spring-baton -p 8080:8080 2023batondeploy/2023-baton-deploy:latest 1>> build.log 2>> error.log & |