Skip to content

๐Ÿ”จ fix workflow #36

๐Ÿ”จ fix workflow

๐Ÿ”จ fix workflow #36

Workflow file for this run

name: ci
on:
push:
branches:
- "main"
pull_request:
branches:
- "main"
jobs:
build:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
-
name : Cache pip modules
id : cache-pip
uses : actions/cache@v3
with :
path : ~/.cache/pip
key : ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-pip-
${{ runner.os }}-
-
name: Install dependencies
if: steps.cache-pip.outputs.cache-hit != 'true'
run: pip install -r requirements.txt
-
name : Cache Docker layers
id : cache
uses : actions/cache@v3
with :
path : /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ hashFiles('**/Dockerfile', '**/requirements.txt') }}
restore-keys: |
${{ runner.os }}-docker-
-
# Build and push to dockerhub
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}:latest
# EC2 ์ธ์Šคํ„ด์Šค ์ ‘์† ๋ฐ ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜ ์‹คํ–‰
-
name: Application Run
uses: appleboy/[email protected]
with:
host: ${{ secrets.EC2_HOST }}
username: ${{ secrets.EC2_USERNAME }}
key: ${{ secrets.EC2_KEY }}
# ๊ธฐ์กด ์ปจํ…Œ์ด๋„ˆ ์ค‘์ง€, ์ด๋ฏธ์ง€ ์‚ญ์ œ
# ์ƒˆ๋กœ์šด ์ด๋ฏธ์ง€ ๋ฐ›์•„์˜ค๊ธฐ
# ์ƒˆ๋กœ์šด ์ด๋ฏธ์ง€ ๊ธฐ๋ฐ˜์œผ๋กœ ์ปจํ…Œ์ด๋„ˆ ์‹คํ–‰
script: |
sudo docker ps -a --filter "name=${{ secrets.PROJECT_NAME }}" --format "{{.ID}}" | xargs -r sudo docker stop
sudo docker ps -a --filter "name=${{ secrets.PROJECT_NAME }}" --format "{{.ID}}" | xargs -r sudo docker rm -f
sudo docker rmi ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}
sudo docker pull ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}
sudo docker run -p ${{ secrets.PORT }}:${{ secrets.PORT }} \
--env-file ${{ secrets.ENV }} \
--name ${{ secrets.PROJECT_NAME }} \
-v /home/ubuntu/resume_ai_chat.db:/app/resume_ai_chat.db \
-d ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.PROJECT_NAME }}