JeffYang52415's picture
refactor: ci/cd
7ee775e unverified
raw
history blame
1.43 kB
name: Docker CD
on:
push:
branches: [main]
paths:
- "Dockerfile"
- ".dockerignore"
- "docker-compose.yml"
- "pyproject.toml"
- "poetry.lock"
pull_request:
branches: [main]
paths:
- "Dockerfile"
- ".dockerignore"
- "docker-compose.yml"
- "pyproject.toml"
- "poetry.lock"
jobs:
docker:
# Only run this job if:
# 1. It's a push to main (merge), OR
# 2. It's a pull request
if: github.event_name == 'push' || github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Only run Docker login and push when merging to main
- name: Login to Docker Hub
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
# Only push when merging to main
push: ${{ github.event_name == 'push' && github.ref == 'refs/heads/main' }}
tags: jeff52415/llmdataparser:latest
cache-from: type=registry,ref=jeff52415/llmdataparser:latest
cache-to: type=inline