Skip to content

Commit

Permalink
extract workflow args
Browse files Browse the repository at this point in the history
  • Loading branch information
sky-bro committed Jun 24, 2024
1 parent 93ff389 commit fa01e70
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
24 changes: 15 additions & 9 deletions .github/workflows/build-one-version.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,19 @@ on:
tags:
required: true
type: string
registry_image:
required: false
default: 'skybro/ubuntu-cn'
type: string
build_args:
required: false
type: string
secrets:
DOCKER_USER:
required: true
DOCKER_PASSWORD:
required: true

env:
REGISTRY_IMAGE: skybro/ubuntu-cn

jobs:
get-first-tag:
runs-on: ubuntu-latest
Expand Down Expand Up @@ -42,7 +46,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
images: ${{ inputs.registry_image }}
tags: |
${{ inputs.tags }}
- name: Set up QEMU
Expand All @@ -60,9 +64,11 @@ jobs:
with:
context: .
platforms: ${{ matrix.platform }}
build-args: VERSION=${{ needs.get-first-tag.outputs.first_tag }}
build-args: |
${{ inputs.build-args }}
VERSION=${{ needs.get-first-tag.outputs.first_tag }}
labels: ${{ steps.meta.outputs.labels }}
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
outputs: type=image,name=${{ inputs.registry_image }},push-by-digest=true,name-canonical=true,push=true
- name: Export digest
run: |
mkdir -p /tmp/digests
Expand Down Expand Up @@ -96,7 +102,7 @@ jobs:
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY_IMAGE }}
images: ${{ inputs.registry_image }}
tags: |
${{ inputs.tags }}
- name: Login to Docker Hub
Expand All @@ -108,7 +114,7 @@ jobs:
working-directory: /tmp/digests
run: |
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
$(printf '${{ inputs.registry_image }}@sha256:%s ' *)
- name: Inspect image
run: |
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:$(echo "${{ inputs.tags }}" | head -n1)
docker buildx imagetools inspect ${{ inputs.registry_image }}:$(echo "${{ inputs.tags }}" | head -n1)
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
name: "Build & Push images"

on:
workflow_dispatch:
push:
paths:
- '.github/workflows/main.yml'
Expand Down

0 comments on commit fa01e70

Please sign in to comment.