Skip to content

Commit c9766c1

Browse files
reegnzmikefarah
authored andcommitted
Also push docker images to ghcr.io
With docker-hub starting to introduce a much stricter limit on anonymous pulls, it makes sense to also host the image in ghcr.io as well, allowing users flexibility in where they pull the docker images from. Also with the github action it makes more sense hosting the docker image on github infrastructure. I've introduced a github action for logging into registries as well.
1 parent 337960a commit c9766c1

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

.github/workflows/docker-release.yml

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,19 @@ jobs:
3030
- name: Available platforms
3131
run: echo ${{ steps.buildx.outputs.platforms }} && docker version
3232

33+
- name: Login to Docker Hub
34+
uses: docker/login-action@v3
35+
with:
36+
username: ${{ secrets.DOCKER_USERNAME }}
37+
password: ${{ secrets.DOCKER_PASSWORD }}
38+
39+
- name: Login to GitHub Container Registry
40+
uses: docker/login-action@v3
41+
with:
42+
registry: ghcr.io
43+
username: ${{ github.actor }}
44+
password: ${{ secrets.GITHUB_TOKEN }}
45+
3346
- name: Build and push image
3447
run: |
3548
echo "GithubRef: ${GITHUB_REF}"
@@ -41,7 +54,6 @@ jobs:
4154
PLATFORMS="linux/amd64,linux/ppc64le,linux/arm64,linux/arm/v7"
4255
4356
echo "Building and pushing version ${IMAGE_VERSION} of image ${IMAGE_NAME}"
44-
echo '${{ secrets.DOCKER_PASSWORD }}' | docker login -u '${{ secrets.DOCKER_USERNAME }}' --password-stdin
4557
docker buildx build \
4658
--label "org.opencontainers.image.authors=https://github.com/mikefarah/yq/graphs/contributors" \
4759
--label "org.opencontainers.image.created=$(date --rfc-3339=seconds)" \
@@ -59,6 +71,9 @@ jobs:
5971
-t "${IMAGE_NAME}:${IMAGE_VERSION}" \
6072
-t "${IMAGE_NAME}:4" \
6173
-t "${IMAGE_NAME}:latest" \
74+
-t "ghcr.io/${IMAGE_NAME}:${IMAGE_VERSION}" \
75+
-t "ghcr.io/${IMAGE_NAME}:4" \
76+
-t "ghcr.io/${IMAGE_NAME}:latest" \
6277
.
6378
6479
cd github-action
@@ -79,4 +94,7 @@ jobs:
7994
-t "${IMAGE_NAME}:${IMAGE_VERSION}-githubaction" \
8095
-t "${IMAGE_NAME}:4-githubaction" \
8196
-t "${IMAGE_NAME}:latest-githubaction" \
97+
-t "ghcr.io/${IMAGE_NAME}:${IMAGE_VERSION}-githubaction" \
98+
-t "ghrc.io/${IMAGE_NAME}:4-githubaction" \
99+
-t "ghcr.io/${IMAGE_NAME}:latest-githubaction" \
82100
.

0 commit comments

Comments
 (0)