From 2ea9158a217aa16d820b5e643ec99900b3ee2a02 Mon Sep 17 00:00:00 2001 From: Rahman Yusuf Date: Wed, 5 Jun 2024 19:17:16 +0700 Subject: [PATCH] Add docker build in ci Co-authored-by: vonProteus <699900+vonProteus@users.noreply.github.com> --- .github/workflows/build.yml | 61 ++++++++++++++++++++++++++++++++-- .github/workflows/build_pr.yml | 30 +++++++++++++++-- Dockerfile | 9 +++++ 3 files changed, 96 insertions(+), 4 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 39dcac7e..c877cf0e 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -6,9 +6,66 @@ on: tags: - v* +env: + TEST_TAG: mansuf/mangadex-downloader:test + LATEST_TAG: mansuf/mangadex-downloader:latest + jobs: - build: - name: Build app + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_SECRET_TOKEN }} + + - name: Build and export to Docker + uses: docker/build-push-action@v5 + with: + context: . + load: true + tags: ${{ env.TEST_TAG }} + + - name: Test + run: | + docker run --rm ${{ env.TEST_TAG }} + + - name: Update Docker Hub description + # if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mansuf/mangadex-downloader' + uses: peter-evans/dockerhub-description@v4 + with: + username: ${{ secrets.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_SECRET_TOKEN }} + repository: mansuf/mangadex-downloader + short-description: ${{ github.event.repository.description }} + + - name: Build and push + # if: startsWith(github.ref, 'refs/tags/') && github.repository == 'mansuf/mangadex-downloader' + uses: docker/build-push-action@v5 + with: + context: . + platforms: | + linux/amd64 + linux/arm64 + linux/arm/v7 + linux/arm/v6 + push: true + tags: | + ${{ env.LATEST_TAG }} + mansuf/mangadex-downloader:${{ github.ref_name }} + + windows-build: + name: Build app & docs (Windows) runs-on: windows-latest strategy: matrix: diff --git a/.github/workflows/build_pr.yml b/.github/workflows/build_pr.yml index 6cf6a285..4c1dceeb 100644 --- a/.github/workflows/build_pr.yml +++ b/.github/workflows/build_pr.yml @@ -7,10 +7,36 @@ on: - 'requirements-optional.txt' - 'docs/*' +env: + TEST_TAG: mansuf/mangadex-downloader:test + LATEST_TAG: mansuf/mangadex-downloader:latest jobs: - build: - name: Build app & docs + docker: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Build and export to Docker + uses: docker/build-push-action@v5 + with: + context: . + load: true + tags: ${{ env.TEST_TAG }} + + - name: Test + run: | + docker run --rm ${{ env.TEST_TAG }} + + windows-build: + name: Build app & docs (Windows) runs-on: windows-latest strategy: matrix: diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 00000000..12631ac3 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,9 @@ +FROM python:3.11 + +RUN pip install .[optional] + +WORKDIR /downloads + +ENTRYPOINT [ "mangadex-downloader" ] + +CMD [ "--help" ] \ No newline at end of file