mirror of
https://github.com/ZeroCatDev/ClassworksKV.git
synced 2025-07-02 04:39:23 +00:00
Remove deprecated Docker image workflow and consolidate Docker publish workflow to streamline image building and pushing for multiple database types.
This commit is contained in:
parent
dfb7413b05
commit
1f56b8032f
57
.github/workflows/docker-image.yml
vendored
57
.github/workflows/docker-image.yml
vendored
@ -1,57 +0,0 @@
|
|||||||
name: Build and Push
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
branches:
|
|
||||||
- main
|
|
||||||
workflow_dispatch:
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
build_and_push:
|
|
||||||
name: Build and Push
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
strategy:
|
|
||||||
matrix:
|
|
||||||
database: [mysql, postgres, sqlite]
|
|
||||||
permissions:
|
|
||||||
packages: write
|
|
||||||
contents: read
|
|
||||||
steps:
|
|
||||||
- name: Check out the repo
|
|
||||||
uses: actions/checkout@v4
|
|
||||||
|
|
||||||
- name: Login to Docker Hub
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Login to GitHub Container Registry
|
|
||||||
uses: docker/login-action@v3
|
|
||||||
with:
|
|
||||||
registry: ghcr.io
|
|
||||||
username: ${{ github.actor }}
|
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
|
||||||
|
|
||||||
- name: Extract metadata for Docker
|
|
||||||
id: meta
|
|
||||||
uses: docker/metadata-action@v5
|
|
||||||
with:
|
|
||||||
images: |
|
|
||||||
sunwuyuan/classworks
|
|
||||||
ghcr.io/ZeroCatDev/ClassworksServer
|
|
||||||
tags: |
|
|
||||||
type=sha,suffix=-${{ matrix.database }}
|
|
||||||
type=raw,value=${{ matrix.database }},enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
|
|
||||||
flavor: |
|
|
||||||
latest=${{ github.ref == format('refs/heads/{0}', 'main') && matrix.database == 'sqlite' }}
|
|
||||||
|
|
||||||
- name: Build and push Docker images
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
build-args: |
|
|
||||||
DATABASE_TYPE=${{ matrix.database }}
|
|
||||||
push: ${{ github.event_name != 'pull_request' }}
|
|
||||||
tags: ${{ steps.meta.outputs.tags }}
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
71
.github/workflows/docker-publish.yml
vendored
71
.github/workflows/docker-publish.yml
vendored
@ -3,14 +3,14 @@ name: Docker Build and Push
|
|||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
tags: [ "v*.*.*" ]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
branches: [ "main" ]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
MYSQL_IMAGE_NAME: zerocatdev/classworks-mysql
|
OWNER: zerocatdev
|
||||||
POSTGRES_IMAGE_NAME: zerocatdev/classworks-postgres
|
PROJECT_NAME: classworks
|
||||||
SQLITE_IMAGE_NAME: zerocatdev/classworks-sqlite
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-and-push:
|
build-and-push:
|
||||||
@ -19,68 +19,53 @@ jobs:
|
|||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- db: mysql
|
||||||
|
suffix: -mysql
|
||||||
|
- db: postgres
|
||||||
|
suffix: -postgres
|
||||||
|
- db: sqlite
|
||||||
|
suffix: -sqlite
|
||||||
|
- db: sqlite
|
||||||
|
suffix: ""
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout repository
|
- name: Checkout repository
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Log in to the Container registry
|
- name: Set up Docker Buildx
|
||||||
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
|
- name: Log in to Container registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
with:
|
with:
|
||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Extract metadata (tags, labels)
|
- name: Extract Docker metadata
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
images: ${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PROJECT_NAME }}${{ matrix.suffix }}
|
||||||
${{ env.REGISTRY }}/${{ env.MYSQL_IMAGE_NAME }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.POSTGRES_IMAGE_NAME }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.SQLITE_IMAGE_NAME }}
|
|
||||||
tags: |
|
tags: |
|
||||||
type=ref,event=branch
|
type=ref,event=branch
|
||||||
type=ref,event=pr
|
type=ref,event=pr
|
||||||
type=semver,pattern={{version}}
|
type=semver,pattern={{version}}
|
||||||
type=semver,pattern={{major}}.{{minor}}
|
type=semver,pattern={{major}}.{{minor}}
|
||||||
type=sha,format=long
|
type=sha,format=short
|
||||||
type=raw,value=latest,enable={{is_default_branch}}
|
type=raw,value=latest,enable={{is_default_branch}}
|
||||||
|
|
||||||
# Build and push MySQL image
|
- name: Build and push Docker image
|
||||||
- name: Build and push MySQL image
|
|
||||||
uses: docker/build-push-action@v5
|
uses: docker/build-push-action@v5
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: ${{ github.event_name != 'pull_request' }}
|
||||||
build-args: |
|
build-args: |
|
||||||
DATABASE_TYPE=mysql
|
DATABASE_TYPE=${{ matrix.db }}
|
||||||
tags: |
|
tags: ${{ steps.meta.outputs.tags }}
|
||||||
${{ env.REGISTRY }}/${{ env.MYSQL_IMAGE_NAME }}:${{ github.sha }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.MYSQL_IMAGE_NAME }}:latest
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
|
cache-from: type=gha
|
||||||
# Build and push PostgreSQL image
|
cache-to: type=gha,mode=max
|
||||||
- name: Build and push PostgreSQL image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
build-args: |
|
|
||||||
DATABASE_TYPE=postgres
|
|
||||||
tags: |
|
|
||||||
${{ env.REGISTRY }}/${{ env.POSTGRES_IMAGE_NAME }}:${{ github.sha }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.POSTGRES_IMAGE_NAME }}:latest
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
||||||
|
|
||||||
# Build and push SQLite image
|
|
||||||
- name: Build and push SQLite image
|
|
||||||
uses: docker/build-push-action@v5
|
|
||||||
with:
|
|
||||||
context: .
|
|
||||||
push: true
|
|
||||||
build-args: |
|
|
||||||
DATABASE_TYPE=sqlite
|
|
||||||
tags: |
|
|
||||||
${{ env.REGISTRY }}/${{ env.SQLITE_IMAGE_NAME }}:${{ github.sha }}
|
|
||||||
${{ env.REGISTRY }}/${{ env.SQLITE_IMAGE_NAME }}:latest
|
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
|
Loading…
x
Reference in New Issue
Block a user