Skip to content
This repository was archived by the owner on Nov 6, 2025. It is now read-only.

Commit b035a76

Browse files
committed
add github buildx
1 parent af6b8ef commit b035a76

File tree

2 files changed

+72
-8
lines changed

2 files changed

+72
-8
lines changed

.github/workflows/buildx.yml renamed to .github/workflows/buildx_dockerhub.yml

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: buildx
1+
name: buildx_dockerhub
22

33
on:
44
create:
@@ -30,13 +30,9 @@ jobs:
3030
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
3131
fi
3232
33-
echo ::set-output name=docker_image::${DOCKER_IMAGE}
34-
echo ::set-output name=version::${VERSION}
35-
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
36-
--build-arg VERSION=${VERSION} \
37-
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
38-
--build-arg VCS_REF=${GITHUB_SHA::8} \
39-
${TAGS} --file ./Dockerfile .
33+
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
34+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
35+
echo "buildx_args=--platform ${DOCKER_PLATFORMS} --build-arg VERSION=${VERSION} --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg VCS_REF=${GITHUB_SHA::8} ${TAGS} --file ./Dockerfile ." >> $GITHUB_OUTPUT
4036
# https://github.com/docker/setup-qemu-action
4137
-
4238
name: Set up QEMU
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: buildx_github
2+
3+
on:
4+
create:
5+
tags:
6+
- v*
7+
8+
jobs:
9+
buildx:
10+
runs-on: ubuntu-latest
11+
steps:
12+
-
13+
name: Checkout
14+
uses: actions/checkout@v3
15+
-
16+
name: Prepare
17+
id: prepare
18+
run: |
19+
DOCKER_IMAGE=ghcr.io/windoc/nginx-npm
20+
DOCKER_PLATFORMS=linux/amd64,linux/arm/v7,linux/arm64/v8
21+
VERSION=edge
22+
23+
if [[ $GITHUB_REF == refs/tags/* ]]; then
24+
VERSION=${GITHUB_REF#refs/tags/}
25+
VERSION=$(echo $VERSION | sed 's/^v//g')
26+
fi
27+
28+
TAGS="--tag ${DOCKER_IMAGE}:${VERSION}"
29+
if [[ $VERSION =~ ^[0-9]{1,3} ]]; then
30+
TAGS="$TAGS --tag ${DOCKER_IMAGE}:latest"
31+
fi
32+
33+
echo "docker_image=${DOCKER_IMAGE}" >> $GITHUB_OUTPUT
34+
echo "version=${VERSION}" >> $GITHUB_OUTPUT
35+
echo "buildx_args=--platform ${DOCKER_PLATFORMS} --build-arg VERSION=${VERSION} --build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') --build-arg VCS_REF=${GITHUB_SHA::8} ${TAGS} --file ./Dockerfile ." >> $GITHUB_OUTPUT
36+
# https://github.com/docker/setup-qemu-action
37+
-
38+
name: Set up QEMU
39+
uses: docker/setup-qemu-action@v2
40+
# https://github.com/docker/setup-buildx-action
41+
-
42+
name: Set up Docker Buildx
43+
uses: docker/setup-buildx-action@v2
44+
# with:
45+
# cache-from: type=gha
46+
# cache-to: type=gha,mode=max
47+
-
48+
name: Docker Buildx (build)
49+
run: |
50+
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
51+
-
52+
name: Login to ghcr.io
53+
if: success() && github.event_name != 'pull_request'
54+
uses: docker/login-action@v2
55+
with:
56+
registry: ghcr.io
57+
username: ${{ github.actor }}
58+
password: ${{ secrets.GITHUB_TOKEN }}
59+
-
60+
name: Docker Buildx (push to ghcr.io)
61+
if: success() && github.event_name != 'pull_request'
62+
run: |
63+
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
64+
-
65+
name: Inspect image
66+
if: always() && github.event_name != 'pull_request'
67+
run: |
68+
docker buildx imagetools inspect ${{ steps.prepare.outputs.docker_image }}:${{ steps.prepare.outputs.version }}

0 commit comments

Comments
 (0)