Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
.git
.github
node_modules
npm-debug.log
.DS_Store
160 changes: 57 additions & 103 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -1,78 +1,59 @@
name: Deploy Static Docs
name: Build & Push Static Docs Image

on:
pull_request:
branches:
- main
types:
- closed
push:
branches:
- main
Comment thread
pasibun marked this conversation as resolved.
- develop
workflow_dispatch:
inputs:
run_linkcheck:
description: Run monthly linkcheck job
required: false
type: boolean
default: false
schedule:
- cron: '0 6 1 * *'

jobs:
deploy:
name: Deploy `/docs` via SCP
runs-on: ubuntu-22.04

if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
env:
CONTAINER_REGISTRY: ${{ secrets.CONTAINER_REGISTRY }}

env:
SSH_PRIVATE_KEY: ${{ secrets.SSH_DEPLOY_KEY }}
SSH_HOST: ${{ secrets.SSH_HOST }}
SSH_USER: ${{ secrets.SSH_USER }}
jobs:
build-and-push-web:
name: Build & Push Web Image
runs-on: ubuntu-latest
if: github.event_name != 'schedule' && !(github.event_name == 'workflow_dispatch' && inputs.run_linkcheck)
permissions:
contents: read
packages: write

steps:
- name: Checkout repo
- name: Checkout repository
uses: actions/checkout@v4

# - name: Set up Node.js
# uses: actions/setup-node@v4
# with:
# node-version: 23
#
# - name: Run build script
# run: node build.js

- name: Setup SSH key
run: |
mkdir -p ~/.ssh
echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
chmod 600 ~/.ssh/id_rsa
ssh-keyscan -H "$SSH_HOST" >> ~/.ssh/known_hosts

- name: Set target path based on branch
id: path
run: |
if [[ "${GITHUB_REF##*/}" == "main" ]]; then
echo "dir=${{ secrets.SSH_TARGET_DIR_PROD }}" >> $GITHUB_OUTPUT
else
echo "dir=${{ secrets.SSH_TARGET_DIR_DEV }}" >> $GITHUB_OUTPUT
fi

- name: Copy `.` via rsync
run: |
rsync -avz \
--partial \
--delete \
--exclude='.git/' \
--exclude='.github/' \
--exclude='.gitignore' \
--exclude='.gitattributes' \
--exclude='.DS_Store' \
--exclude='img/' \
--exclude='README.md/' \
-e "ssh -i ~/.ssh/id_rsa" \
. \
"${SSH_USER}@${SSH_HOST}:${{ steps.path.outputs.dir }}/"

- name: Set image name
run: echo "WEB_IMAGE_NAME=${CONTAINER_REGISTRY}/${GITHUB_REPOSITORY,,}" >> "$GITHUB_ENV"

- name: Login to container registry
uses: docker/login-action@v3
with:
registry: ${{ env.CONTAINER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build & push container image
uses: docker/build-push-action@v6
with:
context: .
file: ./Dockerfile
push: true
tags: |
${{ env.WEB_IMAGE_NAME }}:latest
${{ env.WEB_IMAGE_NAME }}:${{ github.sha }}
monthly_linkcheck:
name: Monthly Linkchecker Report
runs-on: ubuntu-22.04
if: github.event_name == 'schedule'
if: github.event_name == 'schedule' || (github.event_name == 'workflow_dispatch' && inputs.run_linkcheck)
steps:
- name: Install linkchecker and jq
run: |
Expand All @@ -89,50 +70,23 @@ jobs:
echo "<p>Linkchecker failed with exit code ${STATUS}</p>" > linkchecker-report.html
fi
echo "status=${STATUS}" >> "$GITHUB_OUTPUT"
exit "$STATUS"

- name: Upload linkchecker report to Slack

- name: Upload linkchecker to Slack
id: slack_upload
if: always()
env:
SLACK_TOKEN: ${{ secrets.SLACK_BOT_TOKEN }}
CHANNEL_ID: ${{ secrets.SLACK_CHANNEL_ID }}
uses: slackapi/slack-github-action@v2.1.1
with:
errors: true
method: files.uploadV2
token: ${{ secrets.SLACK_BOT_TOKEN }}
payload: |
channel_id: ${{ secrets.SLACK_CHANNEL_ID }}
initial_comment: "Linkchecker rapport (exit code ${{ steps.linkchecker.outputs.status }}):"
file: "./linkchecker-report.html"
filename: "linkchecker-report.html"

- name: Fail job when linkchecker finds issues
if: steps.linkchecker.outputs.status != '0'
run: |
set -e
FILESIZE=$(wc -c < linkchecker-report.html)
echo "File size: $FILESIZE"

UPLOAD_JSON=$(curl --silent --request POST \
--url https://slack.com/api/files.getUploadURLExternal \
--header "authorization: Bearer $SLACK_TOKEN" \
--header "content-type: application/x-www-form-urlencoded; charset=utf-8" \
--data filename=linkchecker-report.html \
--data length=$FILESIZE)

echo "UPLOAD_JSON: $UPLOAD_JSON"

UPLOAD_URL=$(echo "$UPLOAD_JSON" | jq -r '.upload_url')
FILE_ID=$(echo "$UPLOAD_JSON" | jq -r '.file_id')

if [ "$UPLOAD_URL" = "null" ] || [ -z "$UPLOAD_URL" ]; then
echo "Upload URL ontbreekt! Slack response: $UPLOAD_JSON"
exit 1
fi

UPLOAD_HTTP_STATUS=$(curl -s -o /dev/null -w "%{http_code}" -X POST \
-F "filename=@linkchecker-report.html" \
"$UPLOAD_URL")

echo "UPLOAD HTTP STATUS: $UPLOAD_HTTP_STATUS"
sleep 5

COMPLETE_RESPONSE=$(curl --silent -X POST \
-H "Authorization: Bearer $SLACK_TOKEN" \
-H "Content-Type: application/json" \
--data "{\"files\":[{\"id\":\"$FILE_ID\"}],\"channel_id\":\"$CHANNEL_ID\",\"initial_comment\":\"Linkchecker rapport (exit code ${{ steps.linkchecker.outputs.status }}):\"}" \
https://slack.com/api/files.completeUploadExternal)

echo "COMPLETE_RESPONSE: $COMPLETE_RESPONSE"
if [ "$(echo "$COMPLETE_RESPONSE" | jq -r '.ok')" != "true" ]; then
echo "Error completing upload: $COMPLETE_RESPONSE"
exit 1
fi
echo "Linkchecker exited with status ${{ steps.linkchecker.outputs.status }}."
exit 1
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ pnpm-debug.log*
# Build output
dist/
build/
serve.json
.temp/
.tmp/
out/
Expand Down
22 changes: 22 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# Build stage: install dependencies and generate the landing page
FROM node:20-alpine AS builder
WORKDIR /app

COPY package*.json ./
COPY scripts ./scripts
COPY pubDomainList.json ./

RUN npm ci

COPY . .
RUN npm run build

# Runtime stage: serve the static site
FROM node:20-alpine
WORKDIR /usr/src/app

COPY --from=builder /app /usr/src/app
ENV PORT=8080
EXPOSE 8080

CMD ["npm", "run", "start"]
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ Deze repository wordt **automatisch bijgewerkt** vanuit andere repositories die
- **Merge de PR alleen als alles klopt**.
- Na merge wordt automatisch gedeployed naar **productie**.

## Index bijwerken

De hoofdpagina (`index.html`) wordt tijdens de build vooraf gegenereerd met Node:

```bash
npm install
npm run generate:index
```

Het script (`scripts/generate-index.js`) leest de mappen in deze repository en bouwt dezelfde inhoudsopgave die eerder via `index.php` dynamisch werd opgebouwd. Draai dit script wanneer er folders bijkomen of verdwijnen zodat de pipeline een volledig statische site oplevert.

---

## Vragen?
Expand Down
Loading
Loading