From ec400b648dc3fbe16a8d7a1f3f8d598cc29f3d4a Mon Sep 17 00:00:00 2001 From: Ed Asriyan Date: Sat, 17 Jun 2023 14:22:54 +0400 Subject: [PATCH] Split workflows into CI and CD --- .github/workflows/cd-push-dockerhub.yml | 47 +++++++++++++ .github/workflows/ci-build-and-test.yml | 78 +++++++++++++++++++++ .github/workflows/ci.yml | 91 ------------------------- README.md | 4 +- 4 files changed, 128 insertions(+), 92 deletions(-) create mode 100644 .github/workflows/cd-push-dockerhub.yml create mode 100644 .github/workflows/ci-build-and-test.yml delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/cd-push-dockerhub.yml b/.github/workflows/cd-push-dockerhub.yml new file mode 100644 index 0000000..00b0581 --- /dev/null +++ b/.github/workflows/cd-push-dockerhub.yml @@ -0,0 +1,47 @@ +name: CD | Push to DockerHub + +on: + workflow_run: + workflows: + - CI | Build & Test + types: + - completed + branches: + - master + +jobs: + push: + name: Run tests + runs-on: ubuntu-latest + strategy: + matrix: + image: [ lottie-to-apng, lottie-to-gif, lottie-to-png, lottie-to-png, lottie-to-webp ] + steps: + - name: Cancel if CI failed + uses: andymckay/cancel-action@0.3 + if: ${{ github.event.workflow_run.conclusion == 'failure' }} + + - name: Download ${{ matrix.image }} image as artefact + uses: ishworkh/docker-image-artifact-download@v2.0.1 + with: + workflow: CI | Build & Test + workflow_run_id: ${{ github.event.workflow_run.workflow.id }} + image: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest + token: ${{ secrets.GITHUB_TOKEN }} + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Push ${{ matrix.image }} + run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest + + - name: Update lottie-to-webp description + uses: peter-evans/dockerhub-description@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + repository: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }} + short-description: Converts Lottie Animations (.json / .lottie) and Telegram stickers (*.tgs) diff --git a/.github/workflows/ci-build-and-test.yml b/.github/workflows/ci-build-and-test.yml new file mode 100644 index 0000000..811e5dd --- /dev/null +++ b/.github/workflows/ci-build-and-test.yml @@ -0,0 +1,78 @@ +name: CI | Build & Test + +on: + push: + pull_request: + +jobs: + build: + name: Build docker images + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - name: Build lottie-to-apng + uses: docker/build-push-action@v3 + with: + target: lottie-to-apng + tags: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-apng:latest + load: true + + - name: Upload lottie-to-apng as artifact + uses: ishworkh/docker-image-artifact-upload@v2.0.1 + with: + image: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-apng:latest + + - name: Build lottie-to-gif + uses: docker/build-push-action@v3 + with: + target: lottie-to-gif + tags: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-gif:latest + load: true + + - name: Upload lottie-to-gif as artifact + uses: ishworkh/docker-image-artifact-upload@v2.0.1 + with: + image: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-gif:latest + + - name: Build lottie-to-png + uses: docker/build-push-action@v3 + with: + target: lottie-to-png + tags: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-png:latest + load: true + + - name: Upload lottie-to-png as artifact + uses: ishworkh/docker-image-artifact-upload@v2.0.1 + with: + image: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-png:latest + + - name: Build lottie-to-webp + uses: docker/build-push-action@v3 + with: + target: lottie-to-webp + tags: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-webp:latest + load: true + + - name: Upload lottie-to-webp as artifact + uses: ishworkh/docker-image-artifact-upload@v2.0.1 + with: + image: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-webp:latest + + test: + name: Run tests + needs: build + runs-on: ubuntu-latest + strategy: + matrix: + image: [ lottie-to-apng, lottie-to-gif, lottie-to-png, lottie-to-webp ] + steps: + - name: Download ${{ matrix.image }} image as artefact + uses: ishworkh/docker-image-artifact-download@v2.0.1 + with: + image: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest + + - uses: actions/checkout@v3 + + - name: Run ${{ matrix.image }} tests + run: docker run --rm -v $(pwd)/test-files:/source ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index 4954c66..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,91 +0,0 @@ -name: Converting Tests - -on: - push: - pull_request: - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Build lottie-to-apng - uses: docker/build-push-action@v3 - with: - target: lottie-to-apng - tags: lottie-to-apng - load: true - - - name: Run lottie-to-apng conversion - run: docker run --rm -v $(pwd)/test-files:/source lottie-to-apng - - - name: Build lottie-to-gif - uses: docker/build-push-action@v3 - with: - target: lottie-to-gif - tags: lottie-to-gif - load: true - - - name: Run lottie-to-gif conversion - run: docker run --rm -v $(pwd)/test-files:/source lottie-to-gif - - - name: Build lottie-to-png - uses: docker/build-push-action@v3 - with: - target: lottie-to-png - tags: lottie-to-png - load: true - - - name: Run lottie-to-png conversion - run: docker run --rm -v $(pwd)/test-files:/source lottie-to-png - - - name: Build lottie-to-webp - uses: docker/build-push-action@v3 - with: - target: lottie-to-webp - tags: lottie-to-webp - load: true - - - name: Run lottie-to-webp conversion - run: docker run --rm -v $(pwd)/test-files:/source lottie-to-webp - - - name: Login to DockerHub - if: github.ref == 'refs/heads/master' - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Push lottie-to-apng - if: github.ref == 'refs/heads/master' - uses: docker/build-push-action@v3 - with: - target: lottie-to-apng - tags: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-apng:latest - push: true - - - name: Push lottie-to-gif - if: github.ref == 'refs/heads/master' - uses: docker/build-push-action@v3 - with: - target: lottie-to-gif - tags: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-gif:latest - push: true - - - name: Push lottie-to-png - if: github.ref == 'refs/heads/master' - uses: docker/build-push-action@v3 - with: - target: lottie-to-png - tags: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-png:latest - push: true - - - name: Push lottie-to-webp - if: github.ref == 'refs/heads/master' - uses: docker/build-push-action@v3 - with: - target: lottie-to-webp - tags: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-webp:latest - push: true diff --git a/README.md b/README.md index f4e00d5..e3e618a 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,6 @@ -# Lottie Animations (.json) and Telegram Stickers (*.tgs) to GIF/PNG/APNG/WEBP converter ![docker workflow](https://github.com/ed-asriyan/tgs-to-gif/actions/workflows/ci.yml/badge.svg) +# Lottie Animations (.json) and Telegram Stickers (*.tgs) to GIF/PNG/APNG/WEBP converter +[![CI | Build & Test](https://github.com/ed-asriyan/tgs-to-gif/actions/workflows/ci-build-and-test.yml/badge.svg)](https://github.com/ed-asriyan/tgs-to-gif/actions/workflows/ci-build-and-test.yml) +[![CD | Push to DockerHub](https://github.com/ed-asriyan/tgs-to-gif/actions/workflows/cd-push-dockerhub.yml/badge.svg)](https://github.com/ed-asriyan/tgs-to-gif/actions/workflows/cd-push-dockerhub.yml)