Skip to content

Commit 79c6f56

Browse files
committed
Add image to ghcr
1 parent 517eeea commit 79c6f56

File tree

1 file changed

+43
-9
lines changed

1 file changed

+43
-9
lines changed

.github/workflows/docker.yml

Lines changed: 43 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ on:
1515
- cron: '30 11 20 * *'
1616

1717
env:
18-
REGISTRY_IMAGE: andy5995/linuxdeploy
18+
DH_REGISTRY_IMAGE: andy5995/linuxdeploy
19+
GHCR_REGISTRY_IMAGE: ghcr.io/andy5995/linuxdeploy-build-helper-container
1920
VERSION: v3
2021

2122
jobs:
@@ -43,15 +44,26 @@ jobs:
4344
id: meta
4445
uses: docker/metadata-action@v5
4546
with:
46-
images: ${{ env.REGISTRY_IMAGE }}
47+
images: |
48+
${{ env.DH_REGISTRY_IMAGE }}
49+
${{ env.GHCR_REGISTRY_IMAGE }}
4750
4851
- name: Set up Docker Buildx
4952
uses: docker/setup-buildx-action@v3
53+
5054
- name: Login to Docker Hub
5155
uses: docker/login-action@v3
5256
with:
5357
username: ${{ secrets.DOCKERHUB_USERNAME }}
5458
password: ${{ secrets.UNCLE_ANDY_DOCKERHUB_ACCESS_TOKEN }}
59+
60+
- name: Login to GitHub Container Registry
61+
uses: docker/login-action@v3
62+
with:
63+
registry: ghcr.io
64+
username: ${{ github.repository_owner }}
65+
password: ${{ secrets.GITHUB_TOKEN }}
66+
5567
- name: Build and push by digest
5668
id: build
5769
uses: docker/build-push-action@v6
@@ -60,9 +72,13 @@ jobs:
6072
build-args: CODENAME=${{ matrix.codename }}
6173
file: ./Dockerfile
6274
labels: ${{ steps.meta.outputs.labels }}
63-
outputs: type=image,name=${{ env.REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
64-
cache-from: type=registry,ref=${{ env.REGISTRY_IMAGE }}:${{ matrix.codename }}-${{ env.PLATFORM_PAIR }}-${{ env.VERSION }}-buildcache
65-
cache-to: type=registry,ref=${{ env.REGISTRY_IMAGE }}:${{ matrix.codename }}-${{ env.PLATFORM_PAIR }}-${{ env.VERSION }}-buildcache,mode=max
75+
outputs: |
76+
type=image,name=${{ env.DH_REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
77+
type=image,name=${{ env.GHCR_REGISTRY_IMAGE }},push-by-digest=true,name-canonical=true,push=true
78+
cache-from: type=registry,ref=${{ env.DH_REGISTRY_IMAGE }}:${{ matrix.codename }}-${{ env.PLATFORM_PAIR }}-${{ env.VERSION }}-buildcache
79+
cache-to: type=registry,ref=${{ env.DH_REGISTRY_IMAGE }}:${{ matrix.codename }}-${{ env.PLATFORM_PAIR }}-${{ env.VERSION }}-buildcache,mode=max
80+
81+
6682
- name: Export digest
6783
run: |
6884
mkdir -p /tmp/digests
@@ -94,25 +110,43 @@ jobs:
94110
path: /tmp/digests
95111
pattern: digests-${{ matrix.codename }}-*
96112
merge-multiple: true
113+
97114
- name: Set up Docker Buildx
98115
uses: docker/setup-buildx-action@v3
116+
99117
- name: Docker meta
100118
id: meta
101119
uses: docker/metadata-action@v5
102120
with:
103-
images: ${{ env.REGISTRY_IMAGE }}
121+
images: |
122+
${{ env.DH_REGISTRY_IMAGE }}
123+
${{ env.GHCR_REGISTRY_IMAGE }}
104124
tags: |
105125
type=raw,value=${{ env.VERSION }}-${{ matrix.codename }}
126+
106127
- name: Login to Docker Hub
107128
uses: docker/login-action@v3
108129
with:
109130
username: ${{ secrets.DOCKERHUB_USERNAME }}
110131
password: ${{ secrets.UNCLE_ANDY_DOCKERHUB_ACCESS_TOKEN }}
132+
133+
- name: Login to GitHub Container Registry
134+
uses: docker/login-action@v3
135+
with:
136+
registry: ghcr.io
137+
username: ${{ github.repository_owner }}
138+
password: ${{ secrets.GITHUB_TOKEN }}
139+
111140
- name: Create manifest list and push
112141
working-directory: /tmp/digests
113142
run: |
114-
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
115-
$(printf '${{ env.REGISTRY_IMAGE }}@sha256:%s ' *)
143+
for build in ${DH_REGISTRY_IMAGE} ${GHCR_REGISTRY_IMAGE}; do
144+
docker buildx imagetools create $(jq -cr '.tags | map("-t " + .) | join(" ")' <<< "$DOCKER_METADATA_OUTPUT_JSON") \
145+
$(printf "${build}@sha256:%s " *)
146+
done
147+
116148
- name: Inspect image
117149
run: |
118-
docker buildx imagetools inspect ${{ env.REGISTRY_IMAGE }}:${{ steps.meta.outputs.version }}
150+
for build in ${DH_REGISTRY_IMAGE} ${GHCR_REGISTRY_IMAGE}; do
151+
docker buildx imagetools inspect ${build}:${{ steps.meta.outputs.version }}
152+
done

0 commit comments

Comments
 (0)