-
Notifications
You must be signed in to change notification settings - Fork 12
105 lines (92 loc) · 3.19 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
name: Docker Image CI
on:
pull_request:
paths:
- 'docker/**'
push:
branches:
- "master"
- "release/**"
paths:
- 'docker/**'
tags:
- "v*.*.*"
release:
types: [published]
workflow_dispatch:
inputs:
push_image:
description: 'Push image to registry'
required: true
default: 'false'
type: choice
options:
- 'true'
- 'false'
env:
REGISTRY: ghcr.io
OWNER: security-tools-alliance
PROJECT: rengine-ng
jobs:
build-and-push:
runs-on: ubuntu-latest
strategy:
matrix:
image: [celery, web, postgres, redis, ollama, certs, proxy]
platform: [linux/amd64, linux/arm64]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Get version
id: get_version
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT
else
echo "VERSION=latest" >> $GITHUB_OUTPUT
fi
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GHCR
if: github.event_name != 'pull_request' || github.event.inputs.push_image == 'true'
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ vars.GHCR_USERNAME }}
password: ${{ secrets.GHCR_PAT }}
- name: Build and push
uses: docker/build-push-action@v6
with:
context: ./docker/${{ matrix.image }}
file: ./docker/${{ matrix.image }}/Dockerfile
push: ${{ github.event_name != 'pull_request' || github.event.inputs.push_image == 'true' }}
tags: |
${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PROJECT }}:rengine-${{ matrix.image }}-${{ steps.get_version.outputs.VERSION }}
${{ env.REGISTRY }}/${{ env.OWNER }}/${{ env.PROJECT }}:rengine-${{ matrix.image }}-latest
platforms: ${{ matrix.platform }}
update-release:
needs: build-and-push
if: github.event_name == 'release' && github.event.action == 'published'
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Update release description
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
release_id=$(curl -s -H "Authorization: token $GITHUB_TOKEN" \
"https://api.github.com/repos/${{ github.repository }}/releases/latest" | \
jq -r .id)
images="celery web postgres redis ollama certs proxy"
image_list=""
for image in $images; do
image_list="${image_list}- ghcr.io/${{ env.OWNER }}/${{ env.PROJECT }}:rengine-${image}-${{ github.ref_name }}\n"
done
body="Docker images for this release:\n${image_list}"
curl -X PATCH -H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
"https://api.github.com/repos/${{ github.repository }}/releases/${release_id}" \
-d "{\"body\": \"$body\"}"