-
Notifications
You must be signed in to change notification settings - Fork 2
107 lines (94 loc) · 3.09 KB
/
ctr.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
101
102
103
104
105
106
107
name: Build & publish ejabberd ctr image
on:
push:
branches:
- "**"
paths:
- 'image/tag'
workflow_dispatch:
inputs:
version:
description: 'type yes - no publishing ...'
required: true
env:
REGISTRY: "ghcr.io"
IMAGE_NAME: "sando38/ejabberd"
PATCH_DIR: "image"
jobs:
build_and_push:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@v4
- name: Extract container image tag
run: |
echo "TAG=$(awk 'END{print}' ${{ env.PATCH_DIR }}/tag)" >> $GITHUB_ENV
echo "REF=$(awk 'END{gsub("-", " "); print $1}' ${{ env.PATCH_DIR }}/tag)" >> $GITHUB_ENV
- name: Checkout ejabberd source code
uses: actions/checkout@v4
with:
repository: processone/ejabberd
path: ejabberd-source
ref: ${{ env.REF }}
- name: Patch source code and prepare build context
working-directory: ./ejabberd-source
run: git apply ../image/${{ env.REF }}/patches/*.patch
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v5
with:
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
${{ env.TAG }}
- name: Build linux/amd64 image
uses: docker/build-push-action@v5
with:
build-args: |
METHOD=direct
VERSION=${{ env.TAG }}
VARIANT=hardened
# cache-from: type=gha
# cache-to: type=gha,mode=max
context: ./ejabberd-source/.
file: ./image/${{ env.REF }}/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
load: true
tags: ${{ steps.meta.outputs.tags }}
- name: Smoke Test
run: |
docker run -d --name ejabberd \
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
docker exec ejabberd ejabberdctl started
docker exec ejabberd ejabberdctl status
docker stop ejabberd
- name: Print container logs
if: failure() || success()
run: docker logs ejabberd
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.EJABBERD_REPO_TOKEN }}
- name: Push linux/amd64 image
uses: docker/build-push-action@v5
if: github.event_name == 'push'
with:
build-args: |
METHOD=direct
VERSION=${{ env.TAG }}
VARIANT=hardened
# cache-from: type=gha
# cache-to: type=gha,mode=max
context: ./ejabberd-source/.
file: ./image/${{ env.REF }}/Dockerfile
labels: ${{ steps.meta.outputs.labels }}
platforms: linux/amd64
push: true
tags: ${{ steps.meta.outputs.tags }}