Skip to content

Commit 19a1eb8

Browse files
committed
added ghcr workflow
1 parent eb53127 commit 19a1eb8

File tree

3 files changed

+177
-5
lines changed

3 files changed

+177
-5
lines changed

.github/workflows/dockerhub-publish.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,27 @@ on:
55
image_name:
66
type: string
77
description: 'The name of your image to be built'
8+
required: true
9+
810
context:
911
type: string
1012
description: 'The directory of your Dockerfile'
13+
required: true
14+
1115
file:
1216
type: string
1317
description: 'The path to your Dockerfile'
18+
required: true
19+
1420
secrets:
1521
DOCKER_USERNAME:
1622
description: 'Your docker hub username'
1723
required: true
24+
1825
DOCKER_PASSWORD:
1926
description: 'Your docker hub password/key'
2027
required: true
28+
2129
DOCKERHUB_NAMESPACE:
2230
description: 'Your docker hub namespace'
2331
required: true

.github/workflows/ghcr-publish.yml

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
name: (Reusable Workflow) Publish to GHCR
2+
on:
3+
workflow_call:
4+
inputs:
5+
image_name:
6+
type: string
7+
description: 'The name of your image to be built'
8+
required: true
9+
context:
10+
type: string
11+
description: 'The directory of your Dockerfile'
12+
required: true
13+
14+
file:
15+
type: string
16+
description: 'The path to your Dockerfile'
17+
required: true
18+
19+
secrets:
20+
GITHUB_TOKEN:
21+
description: 'Your github access token'
22+
required: true
23+
24+
env:
25+
REGISTRY: ghcr.io
26+
27+
jobs:
28+
build-and-push-image:
29+
runs-on: ubuntu-24.04
30+
31+
permissions:
32+
contents: read
33+
packages: write
34+
attestations: write
35+
id-token: write
36+
37+
steps:
38+
- name: Checkout repository
39+
uses: actions/checkout@v4
40+
- name: Log in to the Container registry
41+
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
42+
with:
43+
registry: ${{ env.REGISTRY }}
44+
username: ${{ github.actor }}
45+
password: ${{ secrets.GITHUB_TOKEN }}
46+
47+
- name: Extract metadata (tags, labels) for Docker
48+
id: meta
49+
uses: docker/metadata-action@9ec57ed1fcdbf14dcef7dfbe97b2010124a938b7
50+
with:
51+
images: ${{ env.REGISTRY }}/${{ inputs.image_name }}
52+
53+
- name: Build and push Docker image
54+
id: push
55+
uses: docker/build-push-action@f2a1d5e99d037542a71f64918e516c093c6f3fc4
56+
with:
57+
context: ${{ inputs.context }}
58+
file: ${{ inputs.file }}
59+
push: true
60+
tags: ${{ steps.meta.outputs.tags }}
61+
labels: ${{ steps.meta.outputs.labels }}
62+
63+
- name: Generate artifact attestation
64+
uses: actions/attest-build-provenance@v2
65+
with:
66+
subject-name: ${{ env.REGISTRY }}/${{ inputs.image_name }}
67+
subject-digest: ${{ steps.push.outputs.digest }}
68+
push-to-registry: true
69+

.github/workflows/test-publish.yml

Lines changed: 100 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
- 'testing-actions'
66

77
jobs:
8-
push_proxy:
8+
push_proxy_dockerhub:
99
permissions:
1010
packages: write
1111
contents: read
@@ -22,7 +22,28 @@ jobs:
2222
context: './proxy'
2323
file: './proxy/Dockerfile'
2424

25-
push_database:
25+
push_proxy_ghcr:
26+
permissions:
27+
contents: read
28+
packages: write
29+
attestations: write
30+
id-token: write
31+
32+
uses: ./.github/workflows/ghcr-publish.yml
33+
secrets:
34+
GITHUB_TOKEN:: ${{ secrets.GITHUB_TOKEN }}
35+
with:
36+
image_name: 'qproxy'
37+
context: './proxy'
38+
file: './proxy/Dockerfile'
39+
40+
41+
42+
43+
44+
45+
46+
push_database_dockerhub:
2647
permissions:
2748
packages: write
2849
contents: read
@@ -39,7 +60,27 @@ jobs:
3960
context: './server/database'
4061
file: './server/database/Dockerfile'
4162

42-
push_jobs_server:
63+
push_database_ghcr:
64+
permissions:
65+
contents: read
66+
packages: write
67+
attestations: write
68+
id-token: write
69+
70+
uses: ./.github/workflows/ghcr-publish.yml
71+
secrets:
72+
GITHUB_TOKEN:: ${{ secrets.GITHUB_TOKEN }}
73+
with:
74+
image_name: 'qdb'
75+
context: './server/database'
76+
file: './server/database/Dockerfile'
77+
78+
79+
80+
81+
82+
83+
push_jobs_server_dockerhub:
4384
permissions:
4485
packages: write
4586
contents: read
@@ -56,7 +97,26 @@ jobs:
5697
context: './server'
5798
file: './server/jobsServer.Dockerfile'
5899

59-
push_api:
100+
push_jobs_server_ghcr:
101+
permissions:
102+
contents: read
103+
packages: write
104+
attestations: write
105+
id-token: write
106+
107+
uses: ./.github/workflows/ghcr-publish.yml
108+
secrets:
109+
GITHUB_TOKEN:: ${{ secrets.GITHUB_TOKEN }}
110+
with:
111+
image_name: 'qJobsServer'
112+
context: './server'
113+
file: './server/jobsServer.Dockerfile'
114+
115+
116+
117+
118+
119+
push_api_dockerhub:
60120
permissions:
61121
packages: write
62122
contents: read
@@ -73,7 +133,26 @@ jobs:
73133
context: './server'
74134
file: './server/restAPI.Dockerfile'
75135

76-
push_worker:
136+
push_api_ghcr:
137+
permissions:
138+
contents: read
139+
packages: write
140+
attestations: write
141+
id-token: write
142+
143+
uses: ./.github/workflows/ghcr-publish.yml
144+
secrets:
145+
GITHUB_TOKEN:: ${{ secrets.GITHUB_TOKEN }}
146+
with:
147+
image_name: 'qApi'
148+
context: './server'
149+
file: './server/restAPI.Dockerfile'
150+
151+
152+
153+
154+
155+
push_worker_dockerhub:
77156
permissions:
78157
packages: write
79158
contents: read
@@ -89,3 +168,19 @@ jobs:
89168
image_name: 'qWorker'
90169
context: './server/worker'
91170
file: './server/worker/Dockerfile'
171+
172+
push_worker_ghcr:
173+
permissions:
174+
contents: read
175+
packages: write
176+
attestations: write
177+
id-token: write
178+
179+
uses: ./.github/workflows/ghcr-publish.yml
180+
secrets:
181+
GITHUB_TOKEN:: ${{ secrets.GITHUB_TOKEN }}
182+
with:
183+
image_name: 'qWorker'
184+
context: './server/worker'
185+
file: './server/worker/Dockerfile'
186+

0 commit comments

Comments
 (0)