-
Notifications
You must be signed in to change notification settings - Fork 14
101 lines (94 loc) · 3.23 KB
/
build-custom-image.yaml
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
name: Build and push image to DockerHub and GitHub Container Registry
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
manual-tag:
description: 'Manual Tag'
required: true
default: 'main'
type: string
ghost_version:
description: 'Ghost version'
required: true
default: '5.66.0'
type: string
jobs:
docker:
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v4
-
name: Set up QEMU
uses: docker/setup-qemu-action@v3
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
with:
driver-opts: |
network=host
image=moby/buildkit:master
-
name: Set up GHOST_VERSION and MANUAL_TAG values, depending on event type (push or workflow_dispatch)
id: versions
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
run: |
if [ ${{ env.GITHUB_EVENT_NAME }} == workflow_dispatch ]; then
echo "GHOST_VERSION=${{ github.event.inputs.ghost_version }}" >> $GITHUB_OUTPUT
echo "MANUAL_TAG=${{ github.event.inputs.manual-tag }}" >> $GITHUB_OUTPUT
else
echo "GHOST_VERSION=$(curl -s https://api.github.com/repos/tryghost/ghost/releases/latest | jq '.name' | sed 's/\"//g')" >> $GITHUB_OUTPUT
echo "MANUAL_TAG=main" >> $GITHUB_OUTPUT
fi
- name: Show GHOST_VERSION
run: |
echo ${{ steps.versions.outputs.GHOST_VERSION }}
-
name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
docker.io/${{ secrets.DOCKER_USER }}/${{ github.event.repository.name }}
ghcr.io/${{ github.repository }}
tags: |
type=ref,event=branch
type=ref,event=tag
type=raw,value=${{ steps.versions.outputs.MANUAL_TAG }}
type=raw,value=latest
labels: |
org.opencontainers.image.title=ghost-on-kubernetes
org.opencontainers.image.description=Ghost CMS upstream v5 with node 18-bookworm and gosu
org.opencontainers.image.vendor=https://sredevops.org
org.opencontainers.image.source=https://github.com/sredevopsdev/ghost-on-kubernetes
org.opencontainers.image.documentation=https://github.com/sredevopsdev/ghost-on-kubernetes/blob/main/README.md
-
name: Login to DockerHub
uses: docker/login-action@v3
with:
registry: docker.io
username: ${{ secrets.DOCKER_USER }}
password: ${{ secrets.DOCKER_PASS }}
-
name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
-
name: Build and push
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
GHOST_VERSION=${{ steps.versions.outputs.GHOST_VERSION }}