-
Notifications
You must be signed in to change notification settings - Fork 0
59 lines (58 loc) · 1.76 KB
/
build-push-ghcr.yml
File metadata and controls
59 lines (58 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
on:
workflow_call:
inputs:
context:
description: "The Docker context"
default: "."
type: string
file:
description: "Path to Dockerfile"
type: string
image:
description: "The image name"
default: ghcr.io/${{ github.repository }}
type: string
tags:
description: "List of tags as key-value pair attributes https://github.com/docker/metadata-action/?tab=readme-ov-file#tags-input"
type: string
labels:
description: "List of custom labels https://github.com/docker/metadata-action/?tab=readme-ov-file"
type: string
jobs:
build-and-push-image:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
attestations: write
id-token: write
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ inputs.image }}
tags: ${{ inputs.tags }}
labels: ${{ inputs.labels }}
- name: Setup Buildx
uses: docker/setup-buildx-action@v4
- name: Login to ghcr.io
uses: docker/login-action@v4
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v7
with:
context: ${{ inputs.context }}
file: ${{ inputs.file }}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max