-
Notifications
You must be signed in to change notification settings - Fork 0
85 lines (76 loc) · 2.15 KB
/
build.yml
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
---
name: Build
on:
# push:
# branches:
# - main
pull_request:
branches:
- main
types:
- closed
- opened
- reopened
- synchronize
- auto_merge_enabled
workflow_dispatch:
inputs:
rebuild:
description: "Re build container?"
required: true
default: "false"
type: choice
options:
- "true"
- "false"
no-cache:
description: "Build docker images with no cache"
default: false
required: false
type: boolean
jobs:
builds:
name: Container build
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: read
packages: write
env:
COMMIT_SHORT_SHA: null
steps:
- name: Checkout from repository
uses: actions/[email protected]
- name: Set short git commit SHA
run: |+
set -eux
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$calculatedSha" >> $GITHUB_ENV
- uses: docker/metadata-action@v5
id: meta
with:
images: ghcr.io/${{ github.repository }}
tags: |
# set latest tag for default branch
type=raw,value=latest,enable={{is_default_branch}}
# minimal (short sha)
type=sha,enable=true,prefix=,format=short
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/[email protected]
with:
context: .
file: Dockerfile
push: ${{ contains( github.event.pull_request.merged, true ) || inputs.rebuild == 'true' || github.event_name == 'workflow_dispatch' }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
no-cache: ${{ inputs.no-cache == true }}