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

Commit a8814f0

Browse files
committed
ci: Extract docker build into separate workflow
1 parent 2efbe97 commit a8814f0

File tree

2 files changed

+97
-82
lines changed

2 files changed

+97
-82
lines changed

.github/workflows/main-docker.yml

Lines changed: 96 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
on:
2+
push:
3+
branches:
4+
- "develop"
5+
- "feature/update**"
6+
- "feature/server_esm**"
7+
paths-ignore:
8+
- "docs/**"
9+
- "bin/**"
10+
tags:
11+
- "v*"
12+
workflow_dispatch:
13+
14+
env:
15+
GHCR_REGISTRY: ghcr.io
16+
DOCKERHUB_REGISTRY: docker.io
17+
IMAGE_NAME: ${{ github.repository }}
18+
19+
jobs:
20+
build_docker:
21+
name: Build Docker images
22+
runs-on: ubuntu-latest
23+
permissions:
24+
contents: read
25+
packages: write
26+
attestations: write
27+
id-token: write
28+
steps:
29+
- uses: actions/checkout@v4
30+
- name: Extract metadata (tags, labels) for GHCR image
31+
id: ghcr-meta
32+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
33+
with:
34+
images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
35+
tags:
36+
- name: Extract metadata (tags, labels) for DockerHub image
37+
id: dh-meta
38+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
39+
with:
40+
images: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
41+
- name: Set up node & dependencies
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: 20
45+
cache: "npm"
46+
- run: npm ci
47+
- name: Run the TypeScript build
48+
run: npx tsc
49+
- name: Create server-package.json
50+
run: cat package.json | grep -v electron > server-package.json
51+
- name: Log in to the GHCR container registry
52+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
53+
with:
54+
registry: ${{ env.GHCR_REGISTRY }}
55+
username: ${{ github.actor }}
56+
password: ${{ secrets.GITHUB_TOKEN }}
57+
- uses: docker/setup-buildx-action@v3
58+
- name: Build and push container image to GHCR
59+
uses: docker/build-push-action@v6
60+
id: ghcr-push
61+
with:
62+
context: .
63+
push: true
64+
tags: ${{ steps.ghcr-meta.outputs.tags }}
65+
labels: ${{ steps.ghcr-meta.outputs.labels }}
66+
cache-from: type=gha
67+
cache-to: type=gha,mode=max
68+
- name: Generate and push artifact attestation to GHCR
69+
uses: actions/attest-build-provenance@v1
70+
with:
71+
subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}}
72+
subject-digest: ${{ steps.ghcr-push.outputs.digest }}
73+
push-to-registry: true
74+
- name: Log in to the DockerHub container registry
75+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
76+
with:
77+
registry: ${{ env.DOCKERHUB_REGISTRY }}
78+
username: ${{ secrets.DOCKERHUB_USERNAME }}
79+
password: ${{ secrets.DOCKERHUB_TOKEN }}
80+
- name: Build and push image to DockerHub
81+
uses: docker/build-push-action@v6
82+
id: dh-push
83+
with:
84+
context: .
85+
push: true
86+
tags: ${{ steps.dh-meta.outputs.tags }}
87+
labels: ${{ steps.dh-meta.outputs.labels }}
88+
cache-from: type=gha
89+
cache-to: type=gha,mode=max
90+
- name: Generate and push artifact attestation to DockerHub
91+
uses: actions/attest-build-provenance@v1
92+
with:
93+
subject-name: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME}}
94+
subject-digest: ${{ steps.dh-push.outputs.digest }}
95+
push-to-registry: true
96+

.github/workflows/main.yml

Lines changed: 1 addition & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@ concurrency:
1616
group: ${{ github.workflow }}-${{ github.ref }}
1717
cancel-in-progress: true
1818

19-
env:
20-
GHCR_REGISTRY: ghcr.io
21-
DOCKERHUB_REGISTRY: docker.io
22-
IMAGE_NAME: ${{ github.repository }}
23-
2419
jobs:
2520
build_darwin-x64:
2621
name: Build macOS x86_64
@@ -142,80 +137,4 @@ jobs:
142137
uses: actions/upload-artifact@v4
143138
with:
144139
name: TriliumNext Notes for Windows (Setup)
145-
path: out/make/squirrel.windows/x64/*.exe
146-
build_docker:
147-
name: Build Docker images
148-
runs-on: ubuntu-latest
149-
permissions:
150-
contents: read
151-
packages: write
152-
attestations: write
153-
id-token: write
154-
steps:
155-
- uses: actions/checkout@v4
156-
- name: Extract metadata (tags, labels) for GHCR image
157-
id: ghcr-meta
158-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
159-
with:
160-
images: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
161-
tags:
162-
- name: Extract metadata (tags, labels) for DockerHub image
163-
id: dh-meta
164-
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
165-
with:
166-
images: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
167-
- name: Set up node & dependencies
168-
uses: actions/setup-node@v4
169-
with:
170-
node-version: 20
171-
cache: "npm"
172-
- run: npm ci
173-
- name: Run the TypeScript build
174-
run: npx tsc
175-
- name: Create server-package.json
176-
run: cat package.json | grep -v electron > server-package.json
177-
- name: Log in to the GHCR container registry
178-
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
179-
with:
180-
registry: ${{ env.GHCR_REGISTRY }}
181-
username: ${{ github.actor }}
182-
password: ${{ secrets.GITHUB_TOKEN }}
183-
- uses: docker/setup-buildx-action@v3
184-
- name: Build and push container image to GHCR
185-
uses: docker/build-push-action@v6
186-
id: ghcr-push
187-
with:
188-
context: .
189-
push: true
190-
tags: ${{ steps.ghcr-meta.outputs.tags }}
191-
labels: ${{ steps.ghcr-meta.outputs.labels }}
192-
cache-from: type=gha
193-
cache-to: type=gha,mode=max
194-
- name: Generate and push artifact attestation to GHCR
195-
uses: actions/attest-build-provenance@v1
196-
with:
197-
subject-name: ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}}
198-
subject-digest: ${{ steps.ghcr-push.outputs.digest }}
199-
push-to-registry: true
200-
- name: Log in to the DockerHub container registry
201-
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
202-
with:
203-
registry: ${{ env.DOCKERHUB_REGISTRY }}
204-
username: ${{ secrets.DOCKERHUB_USERNAME }}
205-
password: ${{ secrets.DOCKERHUB_TOKEN }}
206-
- name: Build and push image to DockerHub
207-
uses: docker/build-push-action@v6
208-
id: dh-push
209-
with:
210-
context: .
211-
push: true
212-
tags: ${{ steps.dh-meta.outputs.tags }}
213-
labels: ${{ steps.dh-meta.outputs.labels }}
214-
cache-from: type=gha
215-
cache-to: type=gha,mode=max
216-
- name: Generate and push artifact attestation to DockerHub
217-
uses: actions/attest-build-provenance@v1
218-
with:
219-
subject-name: ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME}}
220-
subject-digest: ${{ steps.dh-push.outputs.digest }}
221-
push-to-registry: true
140+
path: out/make/squirrel.windows/x64/*.exe

0 commit comments

Comments
 (0)