From b86284cc37e43fad164555fff233adaa9a434f22 Mon Sep 17 00:00:00 2001 From: vrenaville Date: Wed, 23 Nov 2022 15:17:00 +0100 Subject: [PATCH] feat: switch to odoo package + github actions --- .github/workflows/workflow.yml | 50 +++++++++++++++++++++++++++++++++ .travis.yml | 47 ------------------------------- Dockerfile-0.12.5 => Dockerfile | 9 +++--- 3 files changed, 54 insertions(+), 52 deletions(-) create mode 100644 .github/workflows/workflow.yml delete mode 100644 .travis.yml rename Dockerfile-0.12.5 => Dockerfile (77%) diff --git a/.github/workflows/workflow.yml b/.github/workflows/workflow.yml new file mode 100644 index 0000000..8eb0e4a --- /dev/null +++ b/.github/workflows/workflow.yml @@ -0,0 +1,50 @@ +name: Test, build and push to github packages +on: + pull_request: + branches: + - 'master' + - 'devel' + push: + branches: + - '*' + tags: + - '*.*.*' + +jobs: + build-images: + if: ${{ github.event_name == 'push' }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - name: Set ENV for branch master/main + if: ${{ github.ref == 'refs/heads/master' }} + run: echo "RELEASE_VERSION=latest" >> $GITHUB_ENV + - name: Set ENV for tags + if: ${{ startsWith(github.ref, 'refs/tags/') }} + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV + - name: Set ENV for specific branch + if: ${{ startsWith(github.ref, 'refs/heads/') && !endsWith(github.ref, '/master') }} + run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}-${GITHUB_SHA}" >> $GITHUB_ENV + - name: Login to ghio + uses: docker/login-action@v1 + with: + registry: ghcr.io + username: ${{ secrets.GH_USER }} + password: ${{ secrets.GH_TOKEN }} + + - name: Extract metadata (tags, labels) for Docker + id: meta-kwkhtmltopdf + uses: docker/metadata-action@v5.0.0 + with: + images: | + ghcr.io/camptocamp/kwkhtmltopdf + + - name: Build + Push kwkhtmltopdf + uses: docker/build-push-action@v2 + with: + context: . + platforms: linux/amd64 + push: true + tags: ${{ steps.meta-kwkhtmltopdf.outputs.tags }} + labels: ${{ steps.meta-kwkhtmltopdf.outputs.labels }} + diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 4a41d68..0000000 --- a/.travis.yml +++ /dev/null @@ -1,47 +0,0 @@ -language: python - -python: 3.6 - -dist: xenial - -services: - - docker - -stages: - - name: test - - name: deploy - if: tag IS present - -install: - - pip install tox-travis - # overwrite default imagemagick policy that prevents reading PDF - - sudo cp tests/travis-imagemagick-policy.xml /etc/ImageMagick-6/policy.xml - - sudo apt-get -y install -f ghostscript - # install wkhtmltopdf for native test - - wget -q -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.xenial_amd64.deb - - sudo apt -y install -f /tmp/wkhtmltox.deb - # build and start server image - - docker build -f Dockerfile-${WKHTMLTOPDF_VERSION} -t kwkhtmltopdf:${WKHTMLTOPDF_VERSION} . - - docker run -d --name kwkhtmltopdf -p 8080:8080 kwkhtmltopdf:${WKHTMLTOPDF_VERSION} - - export KWKHTMLTOPDF_SERVER_URL=http://localhost:8080 - -script: - - tox - -after_script: - - docker logs kwkhtmltopdf - - docker stop kwkhtmltopdf - -jobs: - include: - - stage: test - env: - - WKHTMLTOPDF_VERSION=0.12.5 - - stage: deploy - script: - - echo ${GITHUB_PACKAGE_TOKEN} | docker login ghcr.io --username "${GITHUB_PACKAGE_USER}" --password-stdin - - BUILD_NAME=${WKHTMLTOPDF_VERSION}-${TRAVIS_TAG} - - docker tag kwkhtmltopdf:${WKHTMLTOPDF_VERSION} ghcr.io/camptocamp/kwkhtmltopdf:${BUILD_NAME} - - docker push ghcr.io/camptocamp/kwkhtmltopdf:${BUILD_NAME} - env: - - WKHTMLTOPDF_VERSION=0.12.5 \ No newline at end of file diff --git a/Dockerfile-0.12.5 b/Dockerfile similarity index 77% rename from Dockerfile-0.12.5 rename to Dockerfile index e43267b..04f258c 100644 --- a/Dockerfile-0.12.5 +++ b/Dockerfile @@ -12,18 +12,17 @@ RUN go build kwkhtmltopdf_server.go # second stage: server with wkhtmltopdf -FROM debian:bullseye-slim +FROM debian:bookworm-slim RUN set -x \ && apt update \ - && apt -y install --no-install-recommends wget ca-certificates fonts-liberation2 fonts-nanum-coding fonts-horai-umefont fonts-wqy-microhei \ - && wget -q -O /tmp/wkhtmltox.deb https://github.com/wkhtmltopdf/wkhtmltopdf/releases/download/0.12.5/wkhtmltox_0.12.5-1.buster_amd64.deb \ - && echo "ea8277df4297afc507c61122f3c349af142f31e5 /tmp/wkhtmltox.deb" | sha1sum -c - \ + && apt -y install --no-install-recommends wget ca-certificates fonts-liberation2 fonts-nanum-coding fonts-horai-umefont fonts-wqy-microhei \ + && wget -q -O /tmp/wkhtmltox.deb https://github.com/odoo/wkhtmltopdf/releases/download/nightly/wkhtmltox_0.13.0-1.nightly.bookworm_amd64.deb \ + && echo "a8f28ec5a71d18a4791e48ece56ad7395fd0f935 /tmp/wkhtmltox.deb" | sha1sum -c - \ && apt -y install /tmp/wkhtmltox.deb \ && apt -y purge wget --autoremove \ && apt -y clean \ && rm -rf /var/lib/apt/lists/* - COPY --from=0 /tmp/kwkhtml/kwkhtmltopdf_server /usr/local/bin/ RUN adduser --disabled-password --gecos '' kwkhtmltopdf