From fa450fcf72cf15fe2300a46d071ad7d98ebfea1e Mon Sep 17 00:00:00 2001 From: EndangeredF1sh Date: Wed, 23 Oct 2024 12:26:18 +0800 Subject: [PATCH] readme and ci --- .github/workflows/docker-build-push.yml | 58 +++++++++++++++++++++++++ README.md | 2 +- 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/docker-build-push.yml diff --git a/.github/workflows/docker-build-push.yml b/.github/workflows/docker-build-push.yml new file mode 100644 index 0000000..a25b004 --- /dev/null +++ b/.github/workflows/docker-build-push.yml @@ -0,0 +1,58 @@ +name: Docker Build and Push + +on: + push: + branches: [ "main" ] + paths: + - '**.py' + - 'Dockerfile' + - 'requirements.txt' + pull_request: + branches: [ "main" ] + paths: + - '**.py' + - 'Dockerfile' + - 'requirements.txt' + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Generate build date + id: date + run: echo "BUILD_DATE=$(date +'%Y%m%d')" >> $GITHUB_OUTPUT + + - name: Log in to the Container registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + tags: | + type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }} + type=raw,value=git-${{ github.sha::7 }}-${{ steps.date.outputs.BUILD_DATE }} + + - name: Build and push Docker image + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/README.md b/README.md index 8955936..41b66e6 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ To run the PDF2Audio app: 2. **Run** ```bash - docker run -p 7860:7860 pdf2audio + docker run -d -p 7860:7860 --name pdf2audio pdf2audio ``` 3. **Access the Gradio interface:** `http://localhost:7860`.