-
Notifications
You must be signed in to change notification settings - Fork 1
56 lines (49 loc) · 1.61 KB
/
build-workflow.yaml
File metadata and controls
56 lines (49 loc) · 1.61 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
name: Build and Push Docker Image
on:
workflow_call:
inputs:
build_context:
description: 'Path to the build context'
required: true
type: string
image_name:
description: 'Name of the Docker image'
required: true
type: string
image_version:
description: 'Version/tag for the Docker image'
required: true
type: string
runs_on:
description: 'The type of runner to use'
required: false
type: string
default: 'ubuntu-latest'
jobs:
build-and-push:
name: Build and Push Docker Image
runs-on: ${{ inputs.runs_on }}
permissions:
contents: read
packages: write
steps:
- name: Set up GitHub Actions environment
run: echo "GITHUB_OWNER_LOWER=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v6
with:
context: ${{ inputs.build_context }}
push: true
tags: ghcr.io/${{ env.GITHUB_OWNER_LOWER }}/${{ inputs.image_name }}:${{ inputs.image_version }}
labels: |
org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }}