1
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 :
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
13
14
14
env :
15
- GHCR_REGISTRY : ghcr.io
16
- DOCKERHUB_REGISTRY : docker.io
17
- IMAGE_NAME : ${{ github.repository }}
18
- TEST_TAG : triliumnext/notes:test
19
- PLATFORMS : linux/amd64,linux/arm64
15
+ GHCR_REGISTRY : ghcr.io
16
+ DOCKERHUB_REGISTRY : docker.io
17
+ IMAGE_NAME : ${{ github.repository }}
18
+ TEST_TAG : triliumnext/notes:test
19
+ PLATFORMS : linux/amd64,linux/arm64,linux/arm/v7,linux/arm64/v8
20
20
21
21
jobs :
22
- test_docker :
23
- name : Check Docker build
24
- runs-on : ubuntu-latest
25
- steps :
26
- - name : Checkout the repository
27
- uses : actions/checkout@v4
22
+ test_docker :
23
+ name : Check Docker build
24
+ runs-on : ubuntu-latest
25
+ steps :
26
+ - name : Checkout the repository
27
+ uses : actions/checkout@v4
28
28
29
- - name : Set up Docker Buildx
30
- uses : docker/setup-buildx-action@v3
29
+ - name : Set up Docker Buildx
30
+ uses : docker/setup-buildx-action@v3
31
31
32
- - name : Set up node & dependencies
33
- uses : actions/setup-node@v4
34
- with :
35
- node-version : 20
36
- cache : " npm"
37
-
38
- - run : npm ci
39
-
40
- - name : Run the TypeScript build
41
- run : npx tsc
42
-
43
- - name : Create server-package.json
44
- run : cat package.json | grep -v electron > server-package.json
45
-
46
- - name : Build and export to Docker
47
- uses : docker/build-push-action@v6
48
- with :
49
- context : .
50
- load : true
51
- tags : ${{ env.TEST_TAG }}
52
- cache-from : type=gha
53
- cache-to : type=gha,mode=max
54
-
55
- - name : Run the container in the background
56
- run : docker run -d --rm --name trilium_local ${{ env.TEST_TAG }}
57
-
58
- - name : Wait for the healthchecks to pass
59
- uses : stringbean/docker-healthcheck-action@v1
60
- with :
61
- container : trilium_local
62
- wait-time : 50
63
- require-status : running
64
- require-healthy : true
65
-
66
- build_docker :
67
- name : Build Docker images
68
- runs-on : ubuntu-latest
69
- needs :
70
- - test_docker
71
- permissions :
72
- contents : read
73
- packages : write
74
- attestations : write
75
- id-token : write
76
- steps :
77
- - uses : actions/checkout@v4
78
- - name : Set up QEMU
79
- uses : docker/setup-qemu-action@v3
80
- - name : Extract metadata (tags, labels) for GHCR image
81
- id : ghcr-meta
82
- uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
83
- with :
84
- images : ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
85
- tags :
86
- - name : Extract metadata (tags, labels) for DockerHub image
87
- id : dh-meta
88
- uses : docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
89
- with :
90
- images : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
91
32
- name : Set up node & dependencies
92
33
uses : actions/setup-node@v4
93
34
with :
94
35
node-version : 20
95
36
cache : " npm"
37
+
96
38
- run : npm ci
39
+
97
40
- name : Run the TypeScript build
98
41
run : npx tsc
42
+
99
43
- name : Create server-package.json
100
44
run : cat package.json | grep -v electron > server-package.json
101
- - name : Log in to the GHCR container registry
102
- uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
103
- with :
104
- registry : ${{ env.GHCR_REGISTRY }}
105
- username : ${{ github.actor }}
106
- password : ${{ secrets.GITHUB_TOKEN }}
107
- - uses : docker/setup-buildx-action@v3
108
- - name : Build and push container image to GHCR
109
- uses : docker/build-push-action@v6
110
- id : ghcr-push
111
- with :
112
- context : .
113
- platforms : ${{ env.PLATFORMS }}
114
- push : true
115
- tags : ${{ steps.ghcr-meta.outputs.tags }}
116
- labels : ${{ steps.ghcr-meta.outputs.labels }}
117
- cache-from : type=gha
118
- cache-to : type=gha,mode=max
119
- - name : Generate and push artifact attestation to GHCR
120
- uses : actions/attest-build-provenance@v1
121
- with :
122
- subject-name : ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}}
123
- subject-digest : ${{ steps.ghcr-push.outputs.digest }}
124
- push-to-registry : true
125
- - name : Log in to the DockerHub container registry
126
- uses : docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
127
- with :
128
- registry : ${{ env.DOCKERHUB_REGISTRY }}
129
- username : ${{ secrets.DOCKERHUB_USERNAME }}
130
- password : ${{ secrets.DOCKERHUB_TOKEN }}
131
- - name : Build and push image to DockerHub
45
+
46
+ - name : Build and export to Docker
132
47
uses : docker/build-push-action@v6
133
- id : dh-push
134
48
with :
135
49
context : .
136
- platforms : ${{ env.PLATFORMS }}
137
- push : true
138
- tags : ${{ steps.dh-meta.outputs.tags }}
139
- labels : ${{ steps.dh-meta.outputs.labels }}
50
+ load : true
51
+ tags : ${{ env.TEST_TAG }}
140
52
cache-from : type=gha
141
53
cache-to : type=gha,mode=max
142
- - name : Generate and push artifact attestation to DockerHub
143
- uses : actions/attest-build-provenance@v1
54
+
55
+ - name : Run the container in the background
56
+ run : docker run -d --rm --name trilium_local ${{ env.TEST_TAG }}
57
+
58
+ - name : Wait for the healthchecks to pass
59
+ uses : stringbean/docker-healthcheck-action@v1
144
60
with :
145
- subject-name : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME}}
146
- subject-digest : ${{ steps.dh-push.outputs.digest }}
147
- push-to-registry : true
148
-
61
+ container : trilium_local
62
+ wait-time : 50
63
+ require-status : running
64
+ require-healthy : true
65
+
66
+ build_docker :
67
+ name : Build Docker images
68
+ runs-on : ubuntu-latest
69
+ needs :
70
+ - test_docker
71
+ permissions :
72
+ contents : read
73
+ packages : write
74
+ attestations : write
75
+ id-token : write
76
+ strategy :
77
+ matrix :
78
+ architecture : [linux/amd64, linux/arm64, linux/arm/v7, linux/arm64/v8]
79
+ steps :
80
+ - uses : actions/checkout@v4
81
+ - name : Extract metadata (tags, labels) for GHCR image
82
+ id : ghcr-meta
83
+ uses : docker/metadata-action@v4
84
+ with :
85
+ images : ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME }}
86
+ tags : |
87
+ type=ref,event=branch
88
+ type=ref,event=tag
89
+ type=sha
90
+ - name : Extract metadata (tags, labels) for DockerHub image
91
+ id : dh-meta
92
+ uses : docker/metadata-action@v4
93
+ with :
94
+ images : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME }}
95
+ tags : |
96
+ type=ref,event=branch
97
+ type=ref,event=tag
98
+ type=sha
99
+ - name : Set up node & dependencies
100
+ uses : actions/setup-node@v4
101
+ with :
102
+ node-version : 20
103
+ cache : " npm"
104
+ - run : npm ci
105
+ - name : Run the TypeScript build
106
+ run : npx tsc
107
+ - name : Create server-package.json
108
+ run : cat package.json | grep -v electron > server-package.json
109
+ - name : Log in to the GHCR container registry
110
+ uses : docker/login-action@v2
111
+ with :
112
+ registry : ${{ env.GHCR_REGISTRY }}
113
+ username : ${{ github.actor }}
114
+ password : ${{ secrets.GITHUB_TOKEN }}
115
+ - uses : docker/setup-buildx-action@v3
116
+ - name : Build and push container image to GHCR
117
+ uses : docker/build-push-action@v6
118
+ id : ghcr-push
119
+ with :
120
+ context : .
121
+ platforms : ${{ matrix.architecture }}
122
+ push : true
123
+ tags : ${{ steps.ghcr-meta.outputs.tags }}
124
+ labels : ${{ steps.ghcr-meta.outputs.labels }}
125
+ cache-from : type=gha
126
+ cache-to : type=gha,mode=max
127
+ - name : Generate and push artifact attestation to GHCR
128
+ uses : actions/attest-build-provenance@v1
129
+ with :
130
+ subject-name : ${{ env.GHCR_REGISTRY }}/${{ env.IMAGE_NAME}}
131
+ subject-digest : ${{ steps.ghcr-push.outputs.digest }}
132
+ push-to-registry : true
133
+ - name : Log in to the DockerHub container registry
134
+ uses : docker/login-action@v2
135
+ with :
136
+ registry : ${{ env.DOCKERHUB_REGISTRY }}
137
+ username : ${{ secrets.DOCKERHUB_USERNAME }}
138
+ password : ${{ secrets.DOCKERHUB_TOKEN }}
139
+ - name : Build and push image to DockerHub
140
+ uses : docker/build-push-action@v6
141
+ id : dh-push
142
+ with :
143
+ context : .
144
+ platforms : ${{ matrix.architecture }}
145
+ push : true
146
+ tags : ${{ steps.dh-meta.outputs.tags }}
147
+ labels : ${{ steps.dh-meta.outputs.labels }}
148
+ cache-from : type=gha
149
+ cache-to : type=gha,mode=max
150
+ - name : Generate and push artifact attestation to DockerHub
151
+ uses : actions/attest-build-provenance@v1
152
+ with :
153
+ subject-name : ${{ env.DOCKERHUB_REGISTRY }}/${{ env.IMAGE_NAME}}
154
+ subject-digest : ${{ steps.dh-push.outputs.digest }}
155
+ push-to-registry : true
0 commit comments