From 8d0f1b8d18d00d45c5631dff9af670555ed841d6 Mon Sep 17 00:00:00 2001 From: Elliott Sales de Andrade Date: Thu, 10 Feb 2022 04:43:40 -0500 Subject: [PATCH] Load git repositories via a webhook --- .github/workflows/build-image.yml | 2 ++ Caddyfile | 53 +++++++++++++++++++++++++++++++ Containerfile | 4 ++- Makefile | 2 ++ 4 files changed, 60 insertions(+), 1 deletion(-) diff --git a/.github/workflows/build-image.yml b/.github/workflows/build-image.yml index d1196ba..9922f49 100644 --- a/.github/workflows/build-image.yml +++ b/.github/workflows/build-image.yml @@ -9,6 +9,7 @@ env: REGISTRY: ghcr.io IMAGE_NAME: ${{ github.repository }} CADDY_VERSION: "2.4.6" + CADDY_GIT_VERSION: "1.0.4" jobs: build-and-push-image: @@ -41,6 +42,7 @@ jobs: file: ./Containerfile build-args: | CADDY_VERSION=${{ env.CADDY_VERSION }} + CADDY_GIT_VERSION=${{ env.CADDY_GIT_VERSION }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/Caddyfile b/Caddyfile index da0574b..c8ddee0 100644 --- a/Caddyfile +++ b/Caddyfile @@ -1,3 +1,53 @@ +{ + git { + repo basemap { + base_dir {$SITE_DIR:sites} + url https://github.com/matplotlib/basemap.git + branch gh-pages + } + repo cheatsheets { + base_dir {$SITE_DIR:sites} + url https://github.com/matplotlib/cheatsheets.git + branch gh-pages + } + repo governance { + base_dir {$SITE_DIR:sites} + url https://github.com/matplotlib/governance.git + branch gh-pages + } + repo matplotblog { + base_dir {$SITE_DIR:sites} + url https://github.com/matplotlib/matplotblog.git + branch gh-pages + } + repo matplotlib.github.com { + base_dir {$SITE_DIR:sites} + url https://github.com/matplotlib/matplotlib.github.com.git + branch main + } + repo mpl-altair { + base_dir {$SITE_DIR:sites} + url https://github.com/matplotlib/mpl-altair.git + branch gh-pages + } + repo mpl-bench { + base_dir {$SITE_DIR:sites} + url https://github.com/matplotlib/mpl-bench.git + branch gh-pages + } + repo mpl-brochure-site { + base_dir {$SITE_DIR:sites} + url https://github.com/matplotlib/mpl-brochure-site.git + branch gh-pages + } + repo mpl-third-party { + base_dir {$SITE_DIR:sites} + url https://github.com/matplotlib/mpl-third-party.git + branch gh-pages + } + } +} + # Snippet to allow working with git checkouts of project sites that become # toplevel directories. (subproject) { @@ -10,6 +60,9 @@ try_files {path}.html {path} file_server } + route /webhook/{args.0} { + git update repo {args.0} + } } # Set this variable in the environment when running in production. diff --git a/Containerfile b/Containerfile index 203833e..61e5569 100644 --- a/Containerfile +++ b/Containerfile @@ -1,7 +1,9 @@ ARG CADDY_VERSION=latest +ARG CADDY_GIT_VERSION=latest FROM docker.io/library/caddy:${CADDY_VERSION}-builder AS builder -RUN xcaddy build +RUN xcaddy build \ + --with github.com/greenpau/caddy-git@${CADDY_GIT_VERSION} FROM docker.io/library/caddy:${CADDY_VERSION} diff --git a/Makefile b/Makefile index a9124be..367829d 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ RUNTIME ?= podman CADDY_IMAGE ?= caddy-mpl CADDY_VERSION ?= 2.4.6 +CADDY_GIT_VERSION ?= 1.0.4 serve: mkdir -p sites @@ -15,6 +16,7 @@ serve: image: $(RUNTIME) build \ --build-arg=CADDY_VERSION=$(CADDY_VERSION) \ + --build-arg=CADDY_GIT_VERSION=v$(CADDY_GIT_VERSION) \ -t $(CADDY_IMAGE):$(CADDY_VERSION) \ -f Containerfile