forked from mpiorowski/late-sh
-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (72 loc) · 1.99 KB
/
build.yml
File metadata and controls
79 lines (72 loc) · 1.99 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: build
on:
workflow_call:
inputs:
registry:
required: true
type: string
image_name:
required: true
type: string
image_tag:
required: true
type: string
dockerfile:
required: true
type: string
context:
required: true
type: string
docker_target:
required: false
type: string
environment:
required: false
type: string
outputs:
image_tag:
description: Full image tag that was built and pushed
value: ${{ jobs.build.outputs.image_tag }}
jobs:
build:
name: build_and_push_image
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
permissions:
contents: read
packages: write
outputs:
image_tag: ${{ steps.vars.outputs.image_tag }}
steps:
- name: checkout
uses: actions/checkout@v5
- name: login_to_ghcr
uses: docker/login-action@v4
with:
registry: ${{ inputs.registry }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: resolve_image_tag
id: vars
env:
REGISTRY: ${{ inputs.registry }}
REPOSITORY: ${{ github.repository }}
IMAGE_NAME: ${{ inputs.image_name }}
IMAGE_TAG: ${{ inputs.image_tag }}
run: |
echo "image_tag=$REGISTRY/$REPOSITORY/$IMAGE_NAME:$IMAGE_TAG" >> "$GITHUB_OUTPUT"
- name: setup_qemu
uses: docker/setup-qemu-action@v4
- name: setup_docker_buildx
uses: docker/setup-buildx-action@v4
- name: build_and_push
uses: docker/build-push-action@v7
with:
context: ${{ inputs.context }}
file: ${{ inputs.dockerfile }}
target: ${{ inputs.docker_target }}
platforms: linux/amd64
push: true
tags: ${{ steps.vars.outputs.image_tag }}
cache-from: type=gha
cache-to: type=gha,mode=max