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

Commit ee4544c

Browse files
committed
add steps to push container to DockerHub as well
1 parent 99ca701 commit ee4544c

File tree

1 file changed

+45
-22
lines changed

1 file changed

+45
-22
lines changed

.github/workflows/main.yml

Lines changed: 45 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,20 @@ name: Main
22
on:
33
push:
44
branches:
5-
- 'develop'
6-
- 'feature/update**'
7-
- 'feature/server_esm**'
5+
- "develop"
6+
- "feature/update**"
7+
- "feature/server_esm**"
88
paths-ignore:
9-
- 'docs/**'
10-
- 'bin/**'
9+
- "docs/**"
10+
- "bin/**"
1111

1212
concurrency:
1313
group: ${{ github.workflow }}-${{ github.ref }}
1414
cancel-in-progress: true
1515

1616
env:
17-
REGISTRY: ghcr.io
17+
GHCR_REGISTRY: ghcr.io
18+
DOCKERHUB_REGISTRY: docker.io
1819
IMAGE_NAME: ${{ github.repository }}
1920

2021
jobs:
@@ -140,7 +141,7 @@ jobs:
140141
name: TriliumNext Notes for Windows (Setup)
141142
path: out/make/squirrel.windows/x64/*.exe
142143
build_docker:
143-
name: Build Docker image
144+
name: Build Docker images
144145
runs-on: ubuntu-latest
145146
permissions:
146147
contents: read
@@ -149,40 +150,62 @@ jobs:
149150
id-token: write
150151
steps:
151152
- uses: actions/checkout@v4
152-
- name: Log in to the Container registry
153-
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
153+
- name: Extract metadata (tags, labels) for container GHCR image
154+
id: ghcr-meta
155+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
154156
with:
155-
registry: ${{ env.REGISTRY }}
156-
username: ${{ github.actor }}
157-
password: ${{ secrets.GITHUB_TOKEN }}
158-
- name: Extract metadata (tags, labels) for Docker
159-
id: meta
157+
images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
158+
- name: Extract metadata (tags, labels) for container DockerHub image
159+
id: dh-meta
160160
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
161161
with:
162-
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
162+
images: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
163163
- name: Set up node & dependencies
164164
uses: actions/setup-node@v4
165165
with:
166166
node-version: 20
167167
cache: "npm"
168-
- run: npm ci
168+
- run: npm ci
169169
- name: Run the TypeScript build
170170
run: npx tsc
171171
- name: Create server-package.json
172172
run: cat package.json | grep -v electron > server-package.json
173+
- name: Log in to the GHCR container registry
174+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
175+
with:
176+
registry: ${{ env.GHCR_REGISTRY }}
177+
username: ${{ github.actor }}
178+
password: ${{ secrets.GITHUB_TOKEN }}
173179
- uses: docker/setup-buildx-action@v3
174-
- uses: docker/build-push-action@v6
180+
- name: Build and push container image to GHCR
181+
uses: docker/build-push-action@v6
175182
id: push
176183
with:
177184
context: .
178185
push: true
179-
tags: ${{ steps.meta.outputs.tags }}
180-
labels: ${{ steps.meta.outputs.labels }}
186+
tags: ${{ steps.ghcr-meta.outputs.tags }}
187+
labels: ${{ steps.ghcr-meta.outputs.labels }}
181188
cache-from: type=gha
182189
cache-to: type=gha,mode=max
183-
- name: Generate artifact attestation
190+
- name: Generate and push artifact attestation to GHCR
184191
uses: actions/attest-build-provenance@v1
185192
with:
186-
subject-name: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME}}
193+
subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}}
187194
subject-digest: ${{ steps.push.outputs.digest }}
188-
push-to-registry: true
195+
push-to-registry: true
196+
- name: Log in to the GHCR container registry
197+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
198+
with:
199+
registry: ${{ env.GHCR_REGISTRY }}
200+
username: ${{ github.actor }}
201+
password: ${{ secrets.DOCKERHUB_TOKEN }}
202+
- name: Build and push image to DockerHub
203+
uses: docker/build-push-action@v6
204+
id: push
205+
with:
206+
context: .
207+
push: true
208+
tags: ${{ steps.dh-meta.outputs.tags }}
209+
labels: ${{ steps.dh-meta.outputs.labels }}
210+
cache-from: type=gha
211+
cache-to: type=gha,mode=max

0 commit comments

Comments
 (0)