Skip to content

Commit 89dcd00

Browse files
committed
made new file
1 parent 37d8955 commit 89dcd00

File tree

2 files changed

+71
-9
lines changed

2 files changed

+71
-9
lines changed

.github/workflows/build-push-ghcr.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,6 @@ name: Reusable workflow to build and push docker container to github container r
22

33
on:
44
workflow_call:
5-
secrets:
6-
GIT_AUTH_TOKEN:
7-
required: false
8-
description: 'PAT to publish image'
95
inputs:
106
container-name:
117
required: true
@@ -40,7 +36,7 @@ jobs:
4036
with:
4137
registry: ${{ env.REGISTRY }}
4238
username: ${{ github.actor }}
43-
password: ${{ secrets.GIT_AUTH_TOKEN }}
39+
password: ${{ secrets.GITHUB_TOKEN }}
4440

4541
- name: Extract Docker metadata
4642
id: meta
@@ -61,8 +57,6 @@ jobs:
6157
push: true
6258
platforms: linux/amd64,linux/arm64
6359
tags: ${{ steps.meta.outputs.tags }}
64-
cache-from: type=gha
65-
cache-to: type=gha,mode=max
66-
secrets: |
67-
GIT_AUTH_TOKEN = ${{ secrets.GIT_AUTH_TOKEN }}
60+
cache-from: type=registry,ref=${{ env.REGISTRY }}/${{ inputs.container-name }}:buildcache
61+
cache-to: type=registry,ref=${{ env.REGISTRY }}/${{ inputs.container-name }}:buildcache,mode=max
6862
continue-on-error: true
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
name: Reusable workflow to build and push docker container to github container registry
2+
3+
on:
4+
workflow_call:
5+
secrets:
6+
GIT_AUTH_TOKEN:
7+
required: false
8+
description: 'PAT to publish image'
9+
inputs:
10+
container-name:
11+
required: true
12+
type: string
13+
context:
14+
required: false
15+
type: string
16+
default: '.'
17+
file:
18+
required: false
19+
type: string
20+
default: 'Dockerfile'
21+
branch:
22+
type: string
23+
default: 'main'
24+
25+
env:
26+
REGISTRY: ghcr.io/clubcedille
27+
28+
jobs:
29+
build-and-push:
30+
runs-on: ubuntu-latest
31+
steps:
32+
- name: Check Out Repo
33+
uses: actions/checkout@v4
34+
35+
- name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v3
37+
38+
- name: Log in to the Container registry
39+
uses: docker/login-action@v3
40+
with:
41+
registry: ${{ env.REGISTRY }}
42+
username: ${{ github.actor }}
43+
password: ${{ secrets.GIT_AUTH_TOKEN }}
44+
45+
- name: Extract Docker metadata
46+
id: meta
47+
uses: docker/metadata-action@v5
48+
with:
49+
images: ${{ env.REGISTRY }}/${{ inputs.container-name }}
50+
tags: |
51+
type=ref,event=branch
52+
type=sha
53+
type=raw,value=${{ inputs.branch }},enable=${{ github.event_name == 'workflow_dispatch' }}
54+
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master' }}
55+
56+
- name: Build and push Docker image
57+
uses: docker/build-push-action@v6
58+
with:
59+
context: ${{ inputs.context }}
60+
file: ${{ inputs.file }}
61+
push: true
62+
platforms: linux/amd64,linux/arm64
63+
tags: ${{ steps.meta.outputs.tags }}
64+
cache-from: type=gha
65+
cache-to: type=gha,mode=max
66+
secrets: |
67+
GIT_AUTH_TOKEN = ${{ secrets.GIT_AUTH_TOKEN }}
68+
continue-on-error: true

0 commit comments

Comments
 (0)