From 6340be06aae17cfa159382900e0fbfd5af3f1d75 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 | 39 +++++++ .github/workflows/ci-build-and-test.yml | 78 ++++++++++++++ .github/workflows/ci.yml | 136 ------------------------ README.md | 4 +- 4 files changed, 120 insertions(+), 137 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..7f74bab --- /dev/null +++ b/.github/workflows/cd-push-dockerhub.yml @@ -0,0 +1,39 @@ +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: 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: ${{ matrix.image }} + 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 }} + uses: docker/build-push-action@v3 + with: + target: ${{ matrix.image }} + tags: ${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image }}:latest + push: true diff --git a/.github/workflows/ci-build-and-test.yml b/.github/workflows/ci-build-and-test.yml new file mode 100644 index 0000000..3614d7c --- /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: lottie-to-apng + load: true + + - name: Upload lottie-to-apng as artifact + uses: ishworkh/docker-image-artifact-upload@v2.0.1 + with: + image: 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: Upload lottie-to-gif as artifact + uses: ishworkh/docker-image-artifact-upload@v2.0.1 + with: + image: 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: Upload lottie-to-png as artifact + uses: ishworkh/docker-image-artifact-upload@v2.0.1 + with: + image: 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: Upload lottie-to-webp as artifact + uses: ishworkh/docker-image-artifact-upload@v2.0.1 + with: + image: lottie-to-webp + + 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: ${{ matrix.image }} + + - uses: actions/checkout@v3 + + - name: Run ${{ matrix.image }} tests + run: docker run --rm -v $(pwd)/test-files:/source ${{ matrix.image }} diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index bd5acca..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,136 +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: Update lottie-to-apng description - if: github.ref == 'refs/heads/master' - uses: peter-evans/dockerhub-description@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-apng - short-description: Converts Lottie Animations (.json / .lottie) and Telegram stickers (*.tgs) to APNG - - - - 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: Update lottie-to-gif description - if: github.ref == 'refs/heads/master' - uses: peter-evans/dockerhub-description@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-gif - short-description: Converts Lottie Animations (.json / .lottie) and Telegram stickers (*.tgs) to GIF - - - - 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: Update lottie-to-png description - if: github.ref == 'refs/heads/master' - uses: peter-evans/dockerhub-description@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-png - short-description: Converts Lottie Animations (.json / .lottie) and Telegram stickers (*.tgs) to PNG - - - - 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 - - - name: Update lottie-to-webp description - if: github.ref == 'refs/heads/master' - uses: peter-evans/dockerhub-description@v3 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_TOKEN }} - repository: ${{ secrets.DOCKERHUB_USERNAME }}/lottie-to-webp - short-description: Converts Lottie Animations (.json / .lottie) and Telegram stickers (*.tgs) to WEBP diff --git a/README.md b/README.md index f4e00d5..f6adef1 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 +![docker workflow](https://github.com/ed-asriyan/tgs-to-gif/actions/workflows/ci-build-and-test.yml/badge.svg) +![docker workflow](https://github.com/ed-asriyan/tgs-to-gif/actions/workflows/cd-push-dockerhub.yml/badge.svg)