Skip to content

Commit 501879a

Browse files
committed
refactor: wip
Signed-off-by: Niccolò Fei <[email protected]>
1 parent 06149a9 commit 501879a

File tree

2 files changed

+51
-47
lines changed

2 files changed

+51
-47
lines changed

.github/workflows/barman-base-image.yml

Lines changed: 24 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -4,59 +4,36 @@ on:
44
workflow_dispatch:
55
schedule:
66
- cron: "0 0 * * 0"
7+
push:
8+
branches:
9+
- main
10+
paths:
11+
- 'containers/sidecar-requirements.txt'
712

8-
env:
9-
IMAGE_NAME: "ghcr.io/cloudnative-pg/plugin-barman-cloud-base"
10-
PLATFORMS: "linux/amd64,linux/arm64"
11-
12-
permissions:
13-
contents: write
14-
packages: write
15-
security-events: write
13+
permissions: read-all
1614

1715
jobs:
1816
build:
1917
runs-on: ubuntu-latest
18+
permissions:
19+
packages: write
20+
contents: write
2021
steps:
2122
- name: Checkout
22-
uses: actions/checkout@v5
23-
with:
24-
fetch-depth: 0
25-
26-
- name: Set up QEMU
23+
uses: actions/checkout@v4
24+
- name: Install QEMU static binaries
2725
uses: docker/setup-qemu-action@v3
28-
with:
29-
platforms: ${{ env.PLATFORMS }}
30-
31-
- name: Set up Docker Buildx
32-
uses: docker/setup-buildx-action@v3
33-
34-
- name: Log in to the GitHub Container registry
35-
uses: docker/login-action@v3
36-
with:
37-
registry: ghcr.io
38-
username: ${{ github.actor }}
39-
password: ${{ secrets.GITHUB_TOKEN }}
40-
41-
- name: Build Docker Image
42-
uses: docker/build-push-action@v6
43-
with:
44-
platforms: ${{ env.PLATFORMS }}
45-
context: .
46-
file: ./containers/Dockerfile.barmanbase
47-
push: true
48-
tags: ${{ env.IMAGE_NAME }}:latest
49-
50-
- name: Run Snyk to check Docker image for vulnerabilities
51-
uses: snyk/actions/docker@master
52-
continue-on-error: true
26+
- name: Install Task
27+
uses: arduino/setup-task@v2
28+
- name: Install Dagger
5329
env:
54-
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
55-
with:
56-
image: "${{ env.IMAGE_NAME }}:latest"
57-
args: --severity-threshold=high --file=./containers/Dockerfile.barmanbase
58-
59-
- name: Upload result to GitHub Code Scanning
60-
uses: github/codeql-action/upload-sarif@v3
61-
with:
62-
sarif_file: snyk.sarif
30+
# renovate: datasource=github-tags depName=dagger/dagger versioning=semver
31+
DAGGER_VERSION: 0.18.5
32+
run: |
33+
curl -L https://dl.dagger.io/dagger/install.sh | BIN_DIR=$HOME/.local/bin sh
34+
- name: Publish a barman-base
35+
env:
36+
REGISTRY_USER: ${{ github.actor }}
37+
REGISTRY_PASSWORD: ${{ secrets.GITHUB_TOKEN }}
38+
run: |
39+
task publish-barman-base

Taskfile.yml

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,33 @@ tasks:
377377
build --dir . --file containers/Dockerfile.sidecar --platform linux/amd64 --platform linux/arm64
378378
publish --ref {{.SIDECAR_IMAGE_NAME}} --tags {{.IMAGE_VERSION}}
379379
380+
publish-barman-base:
381+
desc: Build and publish a barman-cloud base container image (sidecar)
382+
vars:
383+
BARMAN_BASE_IMAGE_NAME: ghcr.io/{{.GITHUB_REPOSITORY}}-base{{if not (hasPrefix "refs/heads/main" .GITHUB_REF)}}-testing{{end}}
384+
BARMAN_VERSION:
385+
sh: grep "^barman" containers/sidecar-requirements.in | sed -E 's/.*==([^ ]+)/\1/'
386+
BUILD_DATE:
387+
sh: date +"%Y%m%d%H%M"
388+
requires:
389+
# We expect this to run in a GitHub workflow, so we put a few GitHub-specific vars here
390+
# to prevent running this task locally by accident.
391+
vars:
392+
- CI
393+
- GITHUB_REPOSITORY
394+
- GITHUB_REF
395+
- GITHUB_REF_NAME
396+
- REGISTRY_USER
397+
- REGISTRY_PASSWORD
398+
env:
399+
# renovate: datasource=git-refs depName=docker lookupName=https://github.com/purpleclay/daggerverse currentValue=main
400+
DAGGER_DOCKER_SHA: bba3a4ee46fd663a5577337e2221db56c646a0b7
401+
cmds:
402+
- >
403+
dagger call -m github.com/purpleclay/daggerverse/docker@${DAGGER_DOCKER_SHA}
404+
--registry ghcr.io --username $REGISTRY_USER --password env:REGISTRY_PASSWORD
405+
build --dir . --file containers/Dockerfile.barmanbase --platform linux/amd64 --platform linux/arm64
406+
publish --ref {{.BARMAN_BASE_IMAGE_NAME}} --tags "{{.BARMAN_VERSION}}-{{.BUILD_DATE}}"
380407
381408
controller-gen:
382409
desc: Run controller-gen

0 commit comments

Comments
 (0)