Skip to content

Commit c48bc91

Browse files
authored
Push images to GitHub Container Registry in addition to DockerHub (#9)
1 parent 29f1c1c commit c48bc91

File tree

3 files changed

+88
-22
lines changed

3 files changed

+88
-22
lines changed

.github/workflows/update-latest-image.yml

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,26 @@ jobs:
1717
steps:
1818
- name: Checkout source
1919
uses: actions/checkout@v3
20-
- name: Login to Docker Hub
20+
- name: Login to DockerHub
2121
run: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
2222
env:
2323
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
2424
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
25-
- name: Build
26-
run: make build-latest config=public
27-
- name: Push
28-
run: make push-latest config=public
25+
- name: Build and push to DockerHub
26+
run: |
27+
make build-latest config=dockerhub
28+
make push-latest config=dockerhub
29+
- name: Login to GitHub Container Registry
30+
# v2.2.0
31+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.repository_owner }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Build and push to GitHub Container Registry
37+
run: |
38+
make build-latest config=public
39+
make push-latest config=public
2940
- name: Send alert on failure
3041
if: ${{ failure() }}
3142
uses: zulip/github-actions-zulip/send-message@b62d5a0e48a4d984ea4fce5dd65ba691963d4db4
@@ -45,7 +56,8 @@ jobs:
4556
- name: Checkout source
4657
uses: actions/checkout@v3
4758
- name: Login to GitHub Container Registry
48-
uses: docker/login-action@v1
59+
# v2.2.0
60+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
4961
with:
5062
registry: ghcr.io
5163
username: ${{ github.repository_owner }}
@@ -68,11 +80,11 @@ jobs:
6880
topic: ${{ github.repository }} scheduled job failure
6981
content: ${{ github.server_url}}/${{ github.repository }}/actions/runs/${{ github.run_id }} failed.
7082

71-
prune-untagged-images:
83+
prune-untagged-public-images:
7284
needs:
73-
- rebuild-private-latest-image
85+
- rebuild-public-latest-image
7486

75-
name: Prune untagged images
87+
name: Prune untagged public images
7688
runs-on: ubuntu-latest
7789
steps:
7890
- name: Prune
@@ -94,3 +106,30 @@ jobs:
94106
type: stream
95107
topic: ${{ github.repository }} scheduled job failure
96108
content: ${{ github.server_url}}/${{ github.repository }}/actions/runs/${{ github.run_id }} failed.
109+
110+
prune-untagged-private-images:
111+
needs:
112+
- rebuild-private-latest-image
113+
114+
name: Prune untagged private images
115+
runs-on: ubuntu-latest
116+
steps:
117+
- name: Prune
118+
# v4.1.1
119+
uses: actions/delete-package-versions@0d39a63126868f5eefaa47169615edd3c0f61e20
120+
with:
121+
package-name: 'library-documentation-action-v2-insiders'
122+
package-type: 'container'
123+
min-versions-to-keep: 1
124+
delete-only-untagged-versions: 'true'
125+
- name: Send alert on failure
126+
if: ${{ failure() }}
127+
uses: zulip/github-actions-zulip/send-message@b62d5a0e48a4d984ea4fce5dd65ba691963d4db4
128+
with:
129+
api-key: ${{ secrets.ZULIP_SCHEDULED_JOB_FAILURE_API_KEY }}
130+
email: ${{ secrets.ZULIP_SCHEDULED_JOB_FAILURE_EMAIL }}
131+
organization-url: 'https://ponylang.zulipchat.com/'
132+
to: notifications
133+
type: stream
134+
topic: ${{ github.repository }} scheduled job failure
135+
content: ${{ github.server_url}}/${{ github.repository }}/actions/runs/${{ github.run_id }} failed.

.github/workflows/update-release-image.yml

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,26 @@ jobs:
1717
steps:
1818
- name: Checkout source
1919
uses: actions/checkout@v3
20-
- name: Login to Docker Hub
20+
- name: Login to DockerHub
2121
run: docker login -u "$DOCKER_USERNAME" -p "$DOCKER_PASSWORD"
2222
env:
2323
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
2424
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
25-
- name: Build
26-
run: make build-release config=public
27-
- name: Push
28-
run: make push-release config=public
25+
- name: Build and Push to DockerHub
26+
run: |
27+
make build-release config=dockerhub
28+
make push-release config=dockerhub
29+
- name: Login to GitHub Container Registry
30+
# v2.2.0
31+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
32+
with:
33+
registry: ghcr.io
34+
username: ${{ github.repository_owner }}
35+
password: ${{ secrets.GITHUB_TOKEN }}
36+
- name: Build and Push to GitHub Container Registry
37+
run: |
38+
make build-release config=public
39+
make push-release config=public
2940
- name: Send alert on failure
3041
if: ${{ failure() }}
3142
uses: zulip/github-actions-zulip/send-message@b62d5a0e48a4d984ea4fce5dd65ba691963d4db4
@@ -45,7 +56,8 @@ jobs:
4556
- name: Checkout source
4657
uses: actions/checkout@v3
4758
- name: Login to GitHub Container Registry
48-
uses: docker/login-action@v1
59+
# v2.2.0
60+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
4961
with:
5062
registry: ghcr.io
5163
username: ${{ github.repository_owner }}
@@ -82,12 +94,23 @@ jobs:
8294
env:
8395
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
8496
DOCKER_USERNAME: ${{ secrets.DOCKER_USERNAME }}
85-
- name: Build
86-
run: make build version="${VERSION}" config=public
97+
- name: Build and Push to DockerHub
98+
run: |
99+
make build version="${VERSION}" config=dockerhub
100+
make push version="${VERSION}" config=dockerhub
87101
env:
88102
VERSION: ${{ github.event.client_payload.version }}
89-
- name: Push
90-
run: make push version="${VERSION}" config=public
103+
- name: Login to GitHub Container Registry
104+
# v2.2.0
105+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
106+
with:
107+
registry: ghcr.io
108+
username: ${{ github.repository_owner }}
109+
password: ${{ secrets.GITHUB_TOKEN }}
110+
- name: Build and Push to GitHub Container Registry
111+
run: |
112+
make build version="${VERSION}" config=public
113+
make push version="${VERSION}" config=public
91114
env:
92115
VERSION: ${{ github.event.client_payload.version }}
93116
- name: Send alert on failure
@@ -112,7 +135,8 @@ jobs:
112135
- name: Checkout source
113136
uses: actions/checkout@v3
114137
- name: Login to GitHub Container Registry
115-
uses: docker/login-action@v1
138+
# v2.2.0
139+
uses: docker/login-action@465a07811f14bebb1938fbed4728c6a1ff8901fc
116140
with:
117141
registry: ghcr.io
118142
username: ${{ github.repository_owner }}

Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,20 @@
11
config ?= public
22

33
ifdef config
4-
ifeq (,$(filter $(config),public private))
4+
ifeq (,$(filter $(config),public private dockerhub))
55
$(error Unknown configuration "$(config)")
66
endif
77
endif
88

99
ifeq ($(config),private)
1010
IMAGE := ghcr.io/ponylang/library-documentation-action-v2-insiders
1111
PACKAGE = "git+https://${MATERIAL_INSIDERS_ACCESS}@github.com/squidfunk/mkdocs-material-insiders.git"
12-
else
12+
else ifeq ($(config),dockerhub)
1313
IMAGE = ponylang/library-documentation-action-v2
1414
PACKAGE = "mkdocs-material"
15+
else
16+
IMAGE = ghcr.io/ponylang/library-documentation-action-v2
17+
PACKAGE = "mkdocs-material"
1518
endif
1619

1720
all: pylint

0 commit comments

Comments
 (0)