fix(#111): job name change #89
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: froxy BE Continuous Delivery | |
on: | |
push: | |
branches: | |
- deploy | |
jobs: | |
be-cd: | |
runs-on: ubuntu-20.04 # 빌드가 진행될 환경 설정 | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} # DockerHub 사용자 이름 | |
password: ${{ secrets.DOCKER_PASSWORD }} # DockerHub 비밀번호 | |
#이미지 이름 저장 | |
- name: Set Docker image tag as a variable | |
run: echo "DOCKER_TAG=${{ secrets.DOCKER_USERNAME }}/froxy-server:latest" >> $GITHUB_ENV | |
- name: Create .env file | |
run: | | |
echo "${{ secrets.BE_ENV }}" > ./apps/backend/.env | |
- name: Build Docker image | |
run: | | |
docker build -t $DOCKER_TAG . | |
- name: Push Docker image to Docker Hub | |
run: | | |
docker push $DOCKER_TAG | |
- name: Setup SSH | |
uses: webfactory/ssh-agent@v0.5.3 | |
with: | |
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }} | |
- name: Deploy | |
run: | | |
ssh -o StrictHostKeyChecking=no mun@211.188.48.24 " | |
if [ \$(docker ps -a -q -f name=froxy-container) ]; then | |
docker stop froxy-container | |
docker rm froxy-container | |
fi | |
docker pull ${{ secrets.DOCKER_USERNAME }}/froxy-server:latest && \ | |
docker run --network host -d --name froxy-container -v /var/run/docker.sock:/var/run/docker.sock ${{ secrets.DOCKER_USERNAME }}/froxy-server:latest | |
docker image prune -f | |
" | |