mirror of
https://github.com/yusing/godoxy.git
synced 2025-06-09 13:02:33 +02:00
workflow update
This commit is contained in:
parent
3af094d788
commit
7153fc8bb5
6 changed files with 102 additions and 69 deletions
12
.github/workflows/docker-image-agent.yml
vendored
12
.github/workflows/docker-image-agent.yml
vendored
|
@ -1,12 +0,0 @@
|
||||||
name: Docker Image CI (agent)
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags: ["*"]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-main-workflow:
|
|
||||||
uses: ./.github/workflows/docker-image.yml
|
|
||||||
with:
|
|
||||||
make_args: "agent=1"
|
|
||||||
image_name: ${{ github.repository_owner }}/godoxy-agent
|
|
9
.github/workflows/docker-image-main-old.yml
vendored
9
.github/workflows/docker-image-main-old.yml
vendored
|
@ -1,9 +0,0 @@
|
||||||
name: Docker Image CI (main)
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags: ["*"]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-main-workflow:
|
|
||||||
uses: ./.github/workflows/docker-image.yml
|
|
11
.github/workflows/docker-image-main.yml
vendored
11
.github/workflows/docker-image-main.yml
vendored
|
@ -1,11 +0,0 @@
|
||||||
name: Docker Image CI (main)
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags: ["*"]
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
call-main-workflow:
|
|
||||||
uses: ./.github/workflows/docker-image.yml
|
|
||||||
with:
|
|
||||||
image_name: ${{ github.repository_owner }}/godoxy
|
|
22
.github/workflows/docker-image-nightly.yml
vendored
Normal file
22
.github/workflows/docker-image-nightly.yml
vendored
Normal file
|
@ -0,0 +1,22 @@
|
||||||
|
name: Docker Image CI (nightly)
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- "*" # matches every branch that doesn't contain a '/'
|
||||||
|
- "*/*" # matches every branch containing a single '/'
|
||||||
|
- "**" # matches every branch
|
||||||
|
- "!main" # excludes master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-nightly:
|
||||||
|
uses: ./.github/workflows/docker-image.yml
|
||||||
|
with:
|
||||||
|
image_name: ${{ github.repository_owner }}/godoxy
|
||||||
|
tag: nightly
|
||||||
|
build-nightly-agent:
|
||||||
|
uses: ./.github/workflows/docker-image.yml
|
||||||
|
with:
|
||||||
|
image_name: ${{ github.repository_owner }}/godoxy-agent
|
||||||
|
tag: nightly
|
||||||
|
agent: true
|
20
.github/workflows/docker-image-prod.yml
vendored
Normal file
20
.github/workflows/docker-image-prod.yml
vendored
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
name: Docker Image CI
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-prod:
|
||||||
|
uses: ./.github/workflows/docker-image.yml
|
||||||
|
with:
|
||||||
|
image_name: ${{ github.repository_owner }}/godoxy
|
||||||
|
old_image_name: ${{ github.repository_owner }}/go-proxy
|
||||||
|
tag: latest
|
||||||
|
build-prod-agent:
|
||||||
|
uses: ./.github/workflows/docker-image.yml
|
||||||
|
with:
|
||||||
|
image_name: ${{ github.repository_owner }}/godoxy-agent
|
||||||
|
tag: latest
|
||||||
|
agent: true
|
97
.github/workflows/docker-image.yml
vendored
97
.github/workflows/docker-image.yml
vendored
|
@ -3,25 +3,39 @@ name: Docker Image CI
|
||||||
on:
|
on:
|
||||||
workflow_call:
|
workflow_call:
|
||||||
inputs:
|
inputs:
|
||||||
make_args:
|
tag:
|
||||||
description: "Arguments to pass to make"
|
required: true
|
||||||
type: string
|
type: string
|
||||||
required: false
|
|
||||||
default: ""
|
|
||||||
image_name:
|
image_name:
|
||||||
description: "Image name"
|
required: true
|
||||||
type: string
|
type: string
|
||||||
|
old_image_name:
|
||||||
required: false
|
required: false
|
||||||
default: ${{ github.repository }}
|
type: string
|
||||||
|
agent:
|
||||||
|
required: false
|
||||||
|
default: false
|
||||||
|
type: boolean
|
||||||
|
|
||||||
env:
|
env:
|
||||||
REGISTRY: ghcr.io
|
REGISTRY: ghcr.io
|
||||||
IMAGE_NAME: ${{ inputs.image_name }}
|
MAKE_ARGS: agent=${{ inputs.agent && '1' || '0' }}
|
||||||
|
DIGEST_PATH: /tmp/digests/${{ inputs.agent && 'agent' || 'main' }}
|
||||||
|
DIGEST_NAME_SUFFIX: ${{ inputs.agent && 'agent' || 'main' }}
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
name: Build multi-platform Docker image
|
strategy:
|
||||||
runs-on: ubuntu-22.04
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- runner: ubuntu-latest
|
||||||
|
platform: linux/amd64
|
||||||
|
- runner: ubuntu-24.04-arm
|
||||||
|
platform: linux/arm64
|
||||||
|
|
||||||
|
name: Build ${{ matrix.platform }}
|
||||||
|
runs-on: ${{ matrix.runner }}
|
||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
|
@ -29,14 +43,6 @@ jobs:
|
||||||
id-token: write
|
id-token: write
|
||||||
attestations: write
|
attestations: write
|
||||||
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
platform:
|
|
||||||
- linux/amd64
|
|
||||||
# - linux/arm/v6
|
|
||||||
# - linux/arm/v7
|
|
||||||
- linux/arm64
|
|
||||||
steps:
|
steps:
|
||||||
- name: Prepare
|
- name: Prepare
|
||||||
run: |
|
run: |
|
||||||
|
@ -47,13 +53,15 @@ jobs:
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ inputs.image_name }}
|
||||||
|
tags: |
|
||||||
- name: Set up QEMU
|
type=raw,value=${{ inputs.tag }},event=branch
|
||||||
uses: docker/setup-qemu-action@v3
|
type=ref,event=tag
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
with:
|
||||||
|
platforms: ${{ matrix.platform }}
|
||||||
|
|
||||||
- name: Login to registry
|
- name: Login to registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
@ -68,47 +76,49 @@ jobs:
|
||||||
with:
|
with:
|
||||||
platforms: ${{ matrix.platform }}
|
platforms: ${{ matrix.platform }}
|
||||||
labels: ${{ steps.meta.outputs.labels }}
|
labels: ${{ steps.meta.outputs.labels }}
|
||||||
outputs: type=image,name=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }},push-by-digest=true,name-canonical=true,push=true
|
outputs: type=image,name=${{ env.REGISTRY }}/${{ inputs.image_name }},push-by-digest=true,name-canonical=true,push=true
|
||||||
cache-from: type=gha
|
cache-from: type=gha
|
||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
build-args: |
|
build-args: |
|
||||||
VERSION=${{ github.ref_name }}
|
VERSION=${{ github.ref_name }}
|
||||||
MAKE_ARGS=${{ inputs.make_args }}
|
MAKE_ARGS=${{ env.MAKE_ARGS }}
|
||||||
|
|
||||||
- name: Generate artifact attestation
|
- name: Generate artifact attestation
|
||||||
uses: actions/attest-build-provenance@v1
|
uses: actions/attest-build-provenance@v1
|
||||||
with:
|
with:
|
||||||
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
|
subject-name: ${{ env.REGISTRY }}/${{ inputs.image_name }}
|
||||||
subject-digest: ${{ steps.build.outputs.digest }}
|
subject-digest: ${{ steps.build.outputs.digest }}
|
||||||
push-to-registry: true
|
push-to-registry: true
|
||||||
|
|
||||||
- name: Export digest
|
- name: Export digest
|
||||||
run: |
|
run: |
|
||||||
mkdir -p /tmp/digests
|
mkdir -p ${{ env.DIGEST_PATH }}
|
||||||
digest="${{ steps.build.outputs.digest }}"
|
digest="${{ steps.build.outputs.digest }}"
|
||||||
touch "/tmp/digests/${digest#sha256:}"
|
touch "${{ env.DIGEST_PATH }}/${digest#sha256:}"
|
||||||
|
|
||||||
- name: Upload digest
|
- name: Upload digest
|
||||||
uses: actions/upload-artifact@v4
|
uses: actions/upload-artifact@v4
|
||||||
with:
|
with:
|
||||||
name: digests-${{ env.PLATFORM_PAIR }}
|
name: digests-${{ env.PLATFORM_PAIR }}-${{ env.DIGEST_NAME_SUFFIX }}
|
||||||
path: /tmp/digests/*
|
path: ${{ env.DIGEST_PATH }}/*
|
||||||
if-no-files-found: error
|
if-no-files-found: error
|
||||||
retention-days: 1
|
retention-days: 1
|
||||||
|
|
||||||
merge:
|
merge:
|
||||||
runs-on: ubuntu-22.04
|
needs: build
|
||||||
needs:
|
runs-on: ubuntu-latest
|
||||||
- build
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: read
|
contents: read
|
||||||
packages: write
|
packages: write
|
||||||
id-token: write
|
id-token: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Download digests
|
- name: Download digests
|
||||||
uses: actions/download-artifact@v4
|
uses: actions/download-artifact@v4
|
||||||
with:
|
with:
|
||||||
path: /tmp/digests
|
path: ${{ env.DIGEST_PATH }}
|
||||||
pattern: digests-*
|
pattern: digests-*-${{ env.DIGEST_NAME_SUFFIX }}
|
||||||
merge-multiple: true
|
merge-multiple: true
|
||||||
|
|
||||||
- name: Set up Docker Buildx
|
- name: Set up Docker Buildx
|
||||||
|
@ -118,7 +128,10 @@ jobs:
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v5
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
images: ${{ env.REGISTRY }}/${{ inputs.image_name }}
|
||||||
|
tags: |
|
||||||
|
type=raw,value=${{ inputs.tag }},event=branch
|
||||||
|
type=ref,event=tag
|
||||||
|
|
||||||
- name: Login to registry
|
- name: Login to registry
|
||||||
uses: docker/login-action@v3
|
uses: docker/login-action@v3
|
||||||
|
@ -129,11 +142,21 @@ jobs:
|
||||||
|
|
||||||
- name: Create manifest list and push
|
- name: Create manifest list and push
|
||||||
id: push
|
id: push
|
||||||
working-directory: /tmp/digests
|
working-directory: ${{ env.DIGEST_PATH }}
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
|
||||||
$(printf '${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}@sha256:%s ' *)
|
$(printf '${{ env.REGISTRY }}/${{ inputs.image_name }}@sha256:%s ' *)
|
||||||
|
|
||||||
|
- name: Old image name
|
||||||
|
if: inputs.old_image_name != ''
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools create -t ${{ env.REGISTRY }}/${{ inputs.old_image_name }}:${{ steps.meta.outputs.version }}\
|
||||||
|
${{ env.REGISTRY }}/${{ inputs.image_name }}:${{ steps.meta.outputs.version }}
|
||||||
|
|
||||||
- name: Inspect image
|
- name: Inspect image
|
||||||
run: |
|
run: |
|
||||||
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.meta.outputs.version }}
|
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ inputs.image_name }}:${{ steps.meta.outputs.version }}
|
||||||
|
|
||||||
|
- name: Inspect image (old)
|
||||||
|
run: |
|
||||||
|
docker buildx imagetools inspect ${{ env.REGISTRY }}/${{ inputs.old_image_name }}:${{ steps.meta.outputs.version }}
|
||||||
|
|
Loading…
Add table
Reference in a new issue