Skip to content

Commit

Permalink
ci: refactor Docker setup and enhance GitHub actions
Browse files Browse the repository at this point in the history
- New setup workflow file was added, containing a more detailed installation and configuration instructions for Docker.
- Deduplicated Docker installation and setup steps in docker_publish.yml by incorporating the new setup workflow.
- Centralized the Docker login, setup Buildx, and Docker metadata setup, which were originally repeated in several places.

Signed-off-by: 陳鈞 <[email protected]>
  • Loading branch information
jim60105 committed Nov 29, 2023
1 parent f7c7abf commit 7f2b6ce
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 120 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/docker-reused-setup-steps/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
name: Setup docker

description: Configure the docker workflow.

inputs:
token:
description: "A GitHub PAT"
required: true
tag:
description: "A tag to use for the image"
default: "no_model"

outputs:
tags:
description: "tags"
value: ${{ steps.meta.outputs.tags }}
labels:
description: "labels"
value: ${{ steps.meta.outputs.labels }}

runs:
using: composite
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false

- name: Docker meta data:${{ inputs.tag }}
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/whisperx
tags: |
${{ inputs.tag }}
type=raw,value=latest,enable=${{ inputs.tag == 'no_model' }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Create a Access Token with `read:packages` and `write:packages` scopes
# CR_PAT
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ inputs.token }}
140 changes: 20 additions & 120 deletions .github/workflows/docker_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,59 +20,25 @@ jobs:
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false

- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Docker meta data:no_model
id: meta
uses: docker/metadata-action@v4
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-setup-steps
with:
images: ghcr.io/${{ github.repository_owner }}/whisperx
flavor: |
latest=true
prefix=
suffix=
tags: |
no_model
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Create a Access Token with `read:packages` and `write:packages` scopes
# CR_PAT
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
token: ${{ secrets.CR_PAT }}

- name: Build and push:no_model
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile.no_model
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
platforms: linux/amd64, linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
Expand All @@ -98,59 +64,26 @@ jobs:

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false

- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Docker meta data:${{ matrix.model }}-${{ matrix.lang }}
id: meta
uses: docker/metadata-action@v4
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-setup-steps
with:
images: ghcr.io/${{ github.repository_owner }}/whisperx
flavor: |
latest=false
prefix=
suffix=
tags: |
${{ matrix.model}}-${{ matrix.lang }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Create a Access Token with `read:packages` and `write:packages` scopes
# CR_PAT
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
token: ${{ secrets.CR_PAT }}
tag: ${{ matrix.model }}-${{ matrix.lang }}

- name: Build and push:${{ matrix.model }}-${{ matrix.lang }}
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
WHISPER_MODEL=${{ matrix.model }}
LANG=${{ matrix.lang }}
Expand Down Expand Up @@ -203,59 +136,26 @@ jobs:

# Steps represent a sequence of tasks that will be executed as part of the job
steps:
- name: Free Disk Space (Ubuntu)
uses: jlumbroso/free-disk-space@main
with:
# this might remove tools that are actually needed,
# if set to "true" but frees about 6 GB
tool-cache: true

# all of these default to true, but feel free to set to
# "false" if necessary for your workflow
android: true
dotnet: true
haskell: true
large-packages: true
docker-images: true
swap-storage: false

- name: Checkout
uses: actions/checkout@v3
with:
submodules: true

- name: Docker meta data:${{ matrix.model }}-${{ matrix.lang }}
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository_owner }}/whisperx
flavor: |
latest=false
prefix=
suffix=
tags: |
${{ matrix.model}}-${{ matrix.lang }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

# Create a Access Token with `read:packages` and `write:packages` scopes
# CR_PAT
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
- name: Setup docker
id: setup
uses: ./.github/workflows/docker-reused-setup-steps
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.CR_PAT }}
token: ${{ secrets.CR_PAT }}
tag: ${{ matrix.model }}-${{ matrix.lang }}

- name: Build and push:${{ matrix.model }}-${{ matrix.lang }}
uses: docker/build-push-action@v4
with:
context: .
file: ./Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
tags: ${{ steps.setup.outputs.tags }}
labels: ${{ steps.setup.outputs.labels }}
build-args: |
WHISPER_MODEL=${{ matrix.model }}
LANG=${{ matrix.lang }}
Expand Down

0 comments on commit 7f2b6ce

Please sign in to comment.