temp: 버그 수정 #49
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: Frontend CI/CD Pipeline | |
on: | |
push: | |
branches: [ dev ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Cache Docker layers | |
uses: actions/cache@v2 | |
with: | |
path: /tmp/.buildx-cache | |
key: ${{ runner.os }}-buildx-${{ github.sha }} | |
restore-keys: | | |
${{ runner.os }}-buildx- | |
- name: Docker Login | |
uses: docker/[email protected] | |
with: | |
username: ${{ secrets.DOCKER_HUB_USERNAME }} | |
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }} | |
- name: Build and push Docker image | |
run: | | |
docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/ddokddokhana-frontend:latest . | |
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/ddokddokhana-frontend:latest | |
deploy: | |
runs-on: ubuntu-latest | |
needs: build | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Build & Deploy | |
env: | |
PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
HOSTNAME: ${{secrets.SSH_HOST}} | |
USER_NAME: ${{secrets.USER_NAME}} | |
run: | | |
echo "$PRIVATE_KEY" > private_key && chmod 600 private_key | |
ssh -o StrictHostKeyChecking=no -i private_key ${USER_NAME}@${HOSTNAME} <<'EOF' | |
docker stop frontend | |
docker rm frontend | |
docker pull ${{ secrets.DOCKER_HUB_USERNAME }}/ddokddokhana-frontend:latest | |
docker run -d --name frontend -p 80:80 ${{ secrets.DOCKER_HUB_USERNAME }}/ddokddokhana-frontend:latest | |
EOF |