Skip to content

Commit 6eaf8a5

Browse files
committed
Update Docker publish workflow and README
Workflow: remove `pangolin` branch, require actor != github-actions[bot] to avoid bot recursion, and change `contents` permission to write so the job can push README updates. Add steps (only for non-PR branch refs) to build an amd64 image for size calculation, compute a human-readable image size, update the README marker <!-- IMAGE_SIZE_START -->...<!-- IMAGE_SIZE_END -->, and commit/push the change as github-actions[bot] (with a skip-ci message). README: bump baseline to 2.3.1, update multi-proxy image reference, and insert the computed Docker image size placeholder (41MB in this diff).
1 parent 07bb0e9 commit 6eaf8a5

2 files changed

Lines changed: 63 additions & 4 deletions

File tree

.github/workflows/docker-publish.yml

Lines changed: 60 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,20 @@ on:
55
branches:
66
- main
77
- dev
8-
- pangolin
8+
paths:
9+
- 'Dockerfile'
10+
- '.github/workflows/docker-publish.yml'
11+
- 'web/**'
12+
- 'internal/**'
13+
- 'cmd/**'
14+
- 'config/**'
15+
- 'scripts/**'
16+
- 'go.mod'
17+
- 'go.sum'
18+
- '*.go'
19+
- 'data/**'
20+
- 'docs/**'
21+
922
tags:
1023
- 'v*'
1124
pull_request:
@@ -17,9 +30,10 @@ env:
1730

1831
jobs:
1932
build-and-push:
33+
if: github.actor != 'github-actions[bot]'
2034
runs-on: ubuntu-latest
2135
permissions:
22-
contents: read
36+
contents: write
2337
packages: write
2438

2539
steps:
@@ -76,3 +90,47 @@ jobs:
7690
cache-from: type=gha
7791
cache-to: type=gha,mode=max
7892
platforms: linux/amd64,linux/arm64
93+
94+
- name: Build image for size calculation (linux/amd64)
95+
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/')
96+
uses: docker/build-push-action@v6
97+
with:
98+
context: .
99+
file: ./Dockerfile
100+
push: false
101+
load: true
102+
tags: local/${{ env.IMAGE_NAME }}:size-${{ github.sha }}
103+
cache-from: type=gha
104+
platforms: linux/amd64
105+
106+
- name: Calculate image size
107+
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/')
108+
id: image_size
109+
shell: bash
110+
run: |
111+
IMAGE_REF="local/${{ env.IMAGE_NAME }}:size-${{ github.sha }}"
112+
SIZE_BYTES="$(docker image inspect "${IMAGE_REF}" --format='{{.Size}}')"
113+
SIZE_HUMAN="$(numfmt --to=iec --suffix=B "${SIZE_BYTES}")"
114+
echo "Computed image size: ${SIZE_HUMAN}"
115+
echo "size_human=${SIZE_HUMAN}" >> "${GITHUB_OUTPUT}"
116+
117+
- name: Update README image size
118+
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/')
119+
shell: bash
120+
run: |
121+
SIZE="${{ steps.image_size.outputs.size_human }}"
122+
sed -i -E "s|(<!-- IMAGE_SIZE_START -->)[^<]*(<!-- IMAGE_SIZE_END -->)|\1${SIZE}\2|" README.md
123+
124+
- name: Commit README image size update
125+
if: github.event_name != 'pull_request' && startsWith(github.ref, 'refs/heads/')
126+
shell: bash
127+
run: |
128+
if git diff --quiet -- README.md; then
129+
echo "README image size is already up to date"
130+
exit 0
131+
fi
132+
git config user.name "github-actions[bot]"
133+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
134+
git add README.md
135+
git commit -m "chore(readme): update image size [skip ci]"
136+
git push

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ CrowdSec Manager is a web-based management interface for CrowdSec operations, Tr
1414

1515
## Stable release
1616

17-
- Current baseline: `2.3.0`
18-
- Multi-proxy support: not available in this release
17+
- Current baseline: `2.3.1`
18+
- Multi-proxy support: hhftechnology/crowdsec-manager:independent
19+
- Docker image size (linux/amd64): <!-- IMAGE_SIZE_START -->41MB<!-- IMAGE_SIZE_END -->
1920

2021
### Crowdsec-Manager mobile app.
2122

0 commit comments

Comments
 (0)