-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (94 loc) · 3.07 KB
/
modules-docker-build-push.yaml
File metadata and controls
104 lines (94 loc) · 3.07 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
# Workflow do GitHub Actions para criar e publicar uma imagem Docker no Docker Hub.
#
# IMPORTANTE: Este workflow é chamado por outros workflows e está
# centralizado aqui para facilitar a manutenção entre módulos. Por isso, certifique-se de não introduzir
# mudanças que quebrem a compatibilidade ao modificar este workflow.
name: "modules-docker-build-push"
on:
workflow_call:
inputs:
image_name:
description: "Nome da imagem Docker (ex: gersonrs/minha-app)"
required: true
type: string
context:
description: "Contexto do Docker build (diretório do Dockerfile)"
required: false
type: string
default: "."
dockerfile:
description: "Caminho para o Dockerfile"
required: false
type: string
default: "Dockerfile"
platforms:
description: "Plataformas para build multi-arch (ex: linux/amd64,linux/arm64)"
required: false
type: string
default: "linux/amd64"
registry:
description: "Registro Docker (ex: docker.io/quay.io/ghcr.io)"
required: false
type: string
default: "docker.io"
secrets:
USERNAME:
description: "Username do Docker Hub ou outro registro Docker"
required: true
TOKEN:
description: "Token de acesso do Docker Hub ou outro registro Docker"
required: true
permissions:
id-token: write
packages: write
contents: read
attestations: write
env:
REGISTRY: ${{ inputs.registry }}
jobs:
docker:
runs-on: ubuntu-latest
# Pula o build se o PR foi criado pelo release-please
if: |
github.event_name != 'pull_request' ||
!startsWith(github.head_ref, 'release-please--')
steps:
- name: Checkout
uses: actions/checkout@v6
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ inputs.image_name }}
tags: |
type=ref,event=tag
type=ref,event=pr
type=sha,prefix=
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to DockerHub
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ${{ inputs.registry }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.TOKEN }}
- name: Build and push
id: push
uses: docker/build-push-action@v6
with:
context: ${{ inputs.context }}
file: ${{ inputs.context }}/${{ inputs.dockerfile }}
platforms: ${{ inputs.platforms }}
push: ${{ github.event_name != 'pull_request' }}
load: ${{ github.event_name == 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
annotations: ${{ steps.meta.outputs.annotations }}
cache-from: type=gha
cache-to: type=gha,mode=max
build-args: |
DOCKER_METADATA_OUTPUT_JSON