generated from ghostwriter/wip
-
-
Notifications
You must be signed in to change notification settings - Fork 0
95 lines (83 loc) · 2.81 KB
/
docker-build-push.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
86
87
88
89
90
91
92
93
94
95
name: Docker Build
on:
pull_request:
push:
branches:
- "[0-9]+.[0-9]+.x"
- 'v[0-9]+'
tags:
- "[0-9]+.[0-9]+.[0-9]+"
- 'v[0-9]+.[0-9]+.[0-9]+'
workflow_dispatch:
schedule:
- cron: "0 * * * *" # Runs hourly
concurrency:
group: ${{ github.head_ref || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
packages: write
env:
SUPPORTED_PLATFORMS: "linux/amd64,linux/arm64,linux/arm/v7"
DOCKER_IMAGE: "ghcr.io/${{ github.repository_owner }}/compliance"
jobs:
cleanup:
runs-on: ubuntu-latest
continue-on-error: true
strategy:
fail-fast: false
steps:
- uses: actions/delete-package-versions@v5
with:
package-name: 'compliance'
package-type: 'container'
min-versions-to-keep: 30
delete-only-untagged-versions: 'true'
builder:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.DOCKER_IMAGE }}
labels: |
maintainer=Ghostwriter
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=ref,event=branch
type=ref,event=pr
type=schedule
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
type=sha
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Packages Docker Registry
if: github.event_name != 'pull_request'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Inspect builder
run: |
echo "Name: ${{ steps.buildx.outputs.name }}"
echo "Endpoint: ${{ steps.buildx.outputs.endpoint }}"
echo "Status: ${{ steps.buildx.outputs.status }}"
echo "Flags: ${{ steps.buildx.outputs.flags }}"
echo "Platforms: ${{ steps.buildx.outputs.platforms }}"
- name: Build and Push ${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}
uses: docker/build-push-action@v6
with:
cache-from: type=gha,scope=${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }}
cache-to: type=gha,scope=${{ env.DOCKER_IMAGE }}:${{ steps.meta.outputs.version }},mode=max
platforms: ${{ env.SUPPORTED_PLATFORMS}}
push: ${{ github.event_name != 'pull_request' }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}