Skip to content

Commit

Permalink
Split workflows into CI and CD
Browse files Browse the repository at this point in the history
  • Loading branch information
ed-asriyan committed Jun 17, 2023
1 parent 3fd7882 commit ec400b6
Show file tree
Hide file tree
Showing 4 changed files with 128 additions and 92 deletions.
47 changes: 47 additions & 0 deletions .github/workflows/cd-push-dockerhub.yml
Original file line number Diff line number Diff line change
@@ -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)
78 changes: 78 additions & 0 deletions .github/workflows/ci-build-and-test.yml
Original file line number Diff line number Diff line change
@@ -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
91 changes: 0 additions & 91 deletions .github/workflows/ci.yml

This file was deleted.

4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

<hr/>
<h3 align="center">
Expand Down

0 comments on commit ec400b6

Please sign in to comment.