From: Pietro Monteiro <[email protected]>
ChangeLog:
* .forgejo/workflows/build-containers.yaml: New file.
Signed-off-by: Pietro Monteiro <[email protected]>
---
.forgejo/workflows/build-containers.yaml | 56 ++++++++++++++++++++++++
1 file changed, 56 insertions(+)
create mode 100644 .forgejo/workflows/build-containers.yaml
diff --git a/.forgejo/workflows/build-containers.yaml
b/.forgejo/workflows/build-containers.yaml
new file mode 100644
index 000000000000..862afb052346
--- /dev/null
+++ b/.forgejo/workflows/build-containers.yaml
@@ -0,0 +1,56 @@
+on:
+# push:
+# branches:
+# - trunk
+# # run on changes to any file for ci containers or to this file
+# paths:
+# - .forgejo/workflows/build-containers.yaml
+# - 'contrib/ci-container/**/*'
+ # similar for pull requests
+ pull_request:
+ types: [opened, synchronize, reopened]
+ paths:
+ - .forgejo/workflows/build-containers.yaml
+ - 'contrib/ci-container/**/*'
+
+jobs:
+ containers:
+ runs-on: sourceware-runner
+ container:
+ image: quay.io/buildah/stable:v1.42.2
+ env:
+ # the default overlayfs doesn't work when running on docker, which
uses overlayfs
+ STORAGE_DRIVER: vfs
+ # we can't run containers in docker, so use a chroot to build the image
+ BUILDAH_ISOLATION: chroot
+ steps:
+ - name: install dependencies
+ run: |
+ echo "Installing node.js"
+ dnf -y --setopt=install_weak_deps=False install nodejs
+
+ # Checkout sources
+ - uses: actions/checkout@v4
+
+ - name: build containers
+ run: |
+ echo "Building containers from contrib/ci-container"
+ for DIR in ./contrib/ci-container/*
+ do
+ ! [ -d "$DIR" ] && continue
+ CONTAINER="$(basename "$DIR")"
+ if [ "$FORGEJO_EVENT_NAME" = pull_request ]; then
+ # branch name in lowercase, replace non-alphanumerics with '-',
and remove leading and trailling '-'
+ TAG="$(echo "$FORGEJO_HEAD_REF" | sed -e 's/\(.*\)/\L\1/' -e
's/[^[:alnum:]-]/-/g' -e 's/^-\+//;s/-\+$//')"
+ else
+ # branch name
+ TAG="$FORGEJO_REF_NAME"
+ fi
+ echo "Building $CONTAINER with tag $TAG"
+ buildah build --network=host -f "$DIR/Containerfile" -t
"$CONTAINER:$TAG" "$DIR"
+ echo "Built $CONTAINER:$TAG should push it somewhere"
+ buildah images --json "$CONTAINER:$TAG"
+ echo "Removing container image from localhost"
+ buildah rmi "$CONTAINER:$TAG"
+ buildah rmi --prune
+ done
--
2.52.0