forked from librenms/docker
-
Notifications
You must be signed in to change notification settings - Fork 0
87 lines (76 loc) · 2.86 KB
/
build.yml
File metadata and controls
87 lines (76 loc) · 2.86 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
name: Build and Push to GHCR
# Spustí se pouze jednou pro daný ref, i když přijde více pushů rychle za sebou
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
# Oprávnění pro workflow
permissions:
contents: read # Potřebné pro checkout kódu
packages: write # <--- KLÍČOVÁ ZMĚNA: Nutné pro nahrávání do GitHub Packages / GHCR
on:
push:
branches:
- 'master'
- 'main' # Přidáno pro případ, že váš fork používá 'main'
tags:
- 'v*.*.*'
paths-ignore:
- '**.md'
pull_request:
paths-ignore:
- '**.md'
env:
# <--- ZMĚNA: Dynamické jméno obrazu pro GHCR
# Použije se ghcr.io/VASE_JMENO/NAZEV_REPOZITARE
GHCR_IMAGE: ghcr.io/${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v5
# <--- ZMĚNA: Přihlášení do GitHub Container Registry (ghcr.io)
- name: Login to GitHub Container Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v4
with:
registry: ghcr.io
username: ${{ github.actor }} # Vaše GitHub jméno
password: ${{ secrets.GITHUB_TOKEN }} # Automaticky generovaný token pro tuto akci
# <--- ZMĚNA: Metadata upravená pro GHCR
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.GHCR_IMAGE }} # Použije se proměnná pro GHCR
tags: |
type=edge
type=ref,event=branch
type=ref,event=pr
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/master' }}
labels: |
org.opencontainers.image.title=LibreNMS
org.opencontainers.image.description=Fully featured network monitoring system
org.opencontainers.image.vendor=LibreNMS
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Krok "Build" zůstává stejný, ale použije metadata pro GHCR
- name: Build and push
uses: docker/build-push-action@v6
with:
context: .
platforms: linux/amd64,linux/arm64 # Příklad pro multi-arch build, upravte dle potřeby
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
# <--- ZMĚNA: Ověření manifestu na GHCR
- name: Check manifest
if: github.event_name != 'pull_request'
run: |
docker buildx imagetools inspect ${{ env.GHCR_IMAGE }}:${{ steps.meta.outputs.version }}