This commit is contained in:
+83
-28
@@ -4,37 +4,92 @@ on:
|
|||||||
push:
|
push:
|
||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
env:
|
||||||
|
IMAGE: registry.alocoq.fr/coqresearch:latest
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
deploy:
|
||||||
runs-on: native
|
runs-on: native
|
||||||
timeout-minutes: 15
|
timeout-minutes: 30
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: Build Jekyll in Kubernetes job
|
- name: Build and push image with Kaniko
|
||||||
run: |
|
run: |
|
||||||
cat <<'EOF' | kubectl apply -f -
|
cat <<'EOF' | kubectl apply -f -
|
||||||
apiVersion: batch/v1
|
apiVersion: batch/v1
|
||||||
kind: Job
|
kind: Job
|
||||||
metadata:
|
metadata:
|
||||||
name: jekyll-build
|
name: coqresearch-kaniko
|
||||||
namespace: ci
|
namespace: ci
|
||||||
spec:
|
spec:
|
||||||
backoffLimit: 0
|
backoffLimit: 0
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
restartPolicy: Never
|
restartPolicy: Never
|
||||||
containers:
|
initContainers:
|
||||||
- name: jekyll
|
- name: prepare
|
||||||
image: ruby:3.3-alpine
|
image: ruby:3.3-alpine
|
||||||
command:
|
command:
|
||||||
- sh
|
- sh
|
||||||
- -c
|
- -c
|
||||||
- |
|
- |
|
||||||
apk add --no-cache git build-base
|
set -eux
|
||||||
git clone --depth 1 https://git.alocoq.fr/alois/CoqResearch.git /work
|
apk add --no-cache git build-base
|
||||||
cd /work
|
|
||||||
bundle install
|
|
||||||
bundle exec jekyll build
|
|
||||||
|
|
||||||
EOF
|
git clone --depth 1 https://git.alocoq.fr/alois/CoqResearch.git /work
|
||||||
|
cd /work
|
||||||
|
|
||||||
|
bundle install
|
||||||
|
bundle exec jekyll build
|
||||||
|
|
||||||
|
mkdir -p /workspace/image
|
||||||
|
cp -a /work/_site/. /workspace/image/
|
||||||
|
|
||||||
|
cat > /workspace/image/Dockerfile <<'DOCKER'
|
||||||
|
FROM nginx:alpine
|
||||||
|
COPY . /usr/share/nginx/html/
|
||||||
|
DOCKER
|
||||||
|
volumeMounts:
|
||||||
|
- name: workspace
|
||||||
|
mountPath: /workspace
|
||||||
|
|
||||||
|
containers:
|
||||||
|
- name: kaniko
|
||||||
|
image: gcr.io/kaniko-project/executor:debug
|
||||||
|
args:
|
||||||
|
- --context=dir:///workspace/image
|
||||||
|
- --dockerfile=/workspace/image/Dockerfile
|
||||||
|
- --destination=registry.alocoq.fr/coqresearch:latest
|
||||||
|
volumeMounts:
|
||||||
|
- name: workspace
|
||||||
|
mountPath: /workspace
|
||||||
|
|
||||||
|
volumes:
|
||||||
|
- name: workspace
|
||||||
|
emptyDir: {}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
- name: Wait for build
|
||||||
|
run: |
|
||||||
|
kubectl -n ci wait --for=condition=complete job/coqresearch-kaniko --timeout=1800s
|
||||||
|
|
||||||
|
- name: Show logs
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
kubectl -n ci logs job/coqresearch-kaniko -c prepare || true
|
||||||
|
kubectl -n ci logs job/coqresearch-kaniko -c kaniko || true
|
||||||
|
|
||||||
|
- name: Deploy
|
||||||
|
run: |
|
||||||
|
kubectl -n research set image deployment/research-nginx \
|
||||||
|
research-nginx=registry.alocoq.fr/coqresearch:latest
|
||||||
|
|
||||||
|
kubectl -n research rollout restart deployment/research-nginx
|
||||||
|
kubectl -n research rollout status deployment/research-nginx
|
||||||
|
|
||||||
|
- name: Cleanup
|
||||||
|
if: always()
|
||||||
|
run: |
|
||||||
|
kubectl -n ci delete job coqresearch-kaniko --ignore-not-found=true
|
||||||
Reference in New Issue
Block a user