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
25 changes: 25 additions & 0 deletions .containerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.github/
.claude/
.venv/
.vscode/
.idea/
__pycache__/
site/
tmp-site/
tests/
script/
templates/
*.pyc
.DS_Store
.gitignore
.mlcrc
.pre-commit-config.yaml
mlc_config.json
package.json
package-lock.json
container/Containerfile
.containerignore
README.md
CONTRIBUTING.md
LICENSE.md
relatie-ak-tot-toetsingskaders.csv
4 changes: 0 additions & 4 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ updates:
time: "10:00"
timezone: "Europe/Amsterdam"
open-pull-requests-limit: 5
reviewers:
- "ruthkoole"
groups:
all-github-actions:
patterns:
Expand All @@ -23,8 +21,6 @@ updates:
time: "10:00"
timezone: "Europe/Amsterdam"
open-pull-requests-limit: 5
reviewers:
- "ruthkoole"
groups:
all-pip-packages:
patterns:
Expand Down
161 changes: 161 additions & 0 deletions .github/workflows/preview-build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Preview build and deploy

on:
push:
branches:
- main
pull_request:
branches:
- main
types:
- opened
- reopened
- synchronize
- closed

concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}/preview
ZAD_PROJECT_ID: algor-1ha
ZAD_COMPONENT: component-2

jobs:
build:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Get version
id: version
run: |
echo "version=$(git describe --tags 2>/dev/null || echo 'development')" >> "$GITHUB_OUTPUT"

- name: Determine deployment name and URL
id: deployment
run: |
if [ "${{ github.event_name }}" = "pull_request" ]; then
NAME="pr${{ github.event.pull_request.number }}"
TAG_PREFIX="pr-${{ github.event.pull_request.number }}-"
else
NAME="main"
TAG_PREFIX="main-"
fi
URL="https://${{ env.ZAD_COMPONENT }}-${NAME}-${{ env.ZAD_PROJECT_ID }}.rig.prd1.gn2.quattro.rijksapps.nl/kader/"
echo "name=${NAME}" >> "$GITHUB_OUTPUT"
echo "tag_prefix=${TAG_PREFIX}" >> "$GITHUB_OUTPUT"
echo "url=${URL}" >> "$GITHUB_OUTPUT"

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=sha,format=short,prefix=${{ steps.deployment.outputs.tag_prefix }}

- name: Build and push container image
uses: docker/build-push-action@v6
with:
context: .
file: ./container/Containerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
SITE_URL=${{ steps.deployment.outputs.url }}
VERSION=${{ steps.version.outputs.version }}
cache-from: type=gha
cache-to: type=gha,mode=max

deploy-preview:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
permissions:
deployments: write
pull-requests: write
needs: build
environment:
name: ${{ github.event_name == 'pull_request' && format('pr{0}', github.event.pull_request.number) || 'main' }}
url: ${{ steps.deploy.outputs.url }}
steps:
- name: Deploy to ZAD
id: deploy
uses: RijksICTGilde/zad-actions/deploy@v2
with:
api-key: ${{ secrets.ZAD_API_KEY }}
project-id: ${{ env.ZAD_PROJECT_ID }}
deployment-name: ${{ github.event_name == 'pull_request' && format('pr{0}', github.event.pull_request.number) || 'main' }}
component: ${{ env.ZAD_COMPONENT }}
image: ${{ needs.build.outputs.image }}
comment-on-pr: ${{ github.event_name == 'pull_request' }}
qr-code: ${{ github.event_name == 'pull_request' }}
wait-for-ready: true
path-suffix: /kader/

cleanup-preview:
if: github.event_name == 'pull_request' && github.event.action == 'closed'
runs-on: ubuntu-latest
permissions:
deployments: write
packages: write
pull-requests: write
steps:
- name: Cleanup ZAD deployment
uses: RijksICTGilde/zad-actions/cleanup@v2
with:
api-key: ${{ secrets.ZAD_API_KEY }}
project-id: ${{ env.ZAD_PROJECT_ID }}
deployment-name: pr${{ github.event.pull_request.number }}
delete-github-env: true
delete-github-deployments: true
delete-pr-comment: true

- name: Delete container images for this PR
shell: bash
env:
GH_TOKEN: ${{ github.token }}
CONTAINER_ORG: ${{ github.repository_owner }}
TAG_PREFIX: pr-${{ github.event.pull_request.number }}-
run: |
echo "Deleting container images with tag prefix: $TAG_PREFIX"
CONTAINER_NAME="${{ github.event.repository.name }}/preview"
ENCODED_NAME=$(printf '%s' "$CONTAINER_NAME" | jq -sRr @uri)
VERSIONS=$(gh api "orgs/$CONTAINER_ORG/packages/container/$ENCODED_NAME/versions" 2>/dev/null | \
jq -r --arg prefix "$TAG_PREFIX" '.[] | select(.metadata.container.tags[]? | startswith($prefix)) | .id')
if [ -z "$VERSIONS" ]; then
echo "No versions found with tag prefix: $TAG_PREFIX (may already be deleted)"
exit 0
fi
DELETED_COUNT=0
for VERSION_ID in $VERSIONS; do
if gh api "orgs/$CONTAINER_ORG/packages/container/$ENCODED_NAME/versions/$VERSION_ID" -X DELETE 2>/dev/null; then
echo "Deleted version: $VERSION_ID"
DELETED_COUNT=$((DELETED_COUNT + 1))
else
echo "Failed to delete version: $VERSION_ID"
fi
done
echo "Deleted $DELETED_COUNT container version(s) for PR ${{ github.event.pull_request.number }}"
58 changes: 0 additions & 58 deletions .github/workflows/preview.yaml

This file was deleted.

74 changes: 74 additions & 0 deletions .github/workflows/production-build-and-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
name: Production build and deploy

on:
push:
tags:
- v*

env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
ZAD_PROJECT_ID: algor-1ha
ZAD_COMPONENT: component-2

jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout
uses: actions/checkout@v6
with:
fetch-depth: 0

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=semver,pattern={{version}}

- name: Build and push container image
uses: docker/build-push-action@v6
with:
context: .
file: ./container/Containerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-args: |
SITE_URL=https://algoritmes.overheid.nl/kader/
VERSION=${{ github.ref_name }}
cache-from: type=gha
cache-to: type=gha,mode=max

deploy:
runs-on: ubuntu-latest
needs: build
permissions:
deployments: write
environment:
name: production
steps:
- name: Deploy to ZAD
uses: RijksICTGilde/zad-actions/deploy@v2
with:
api-key: ${{ secrets.ZAD_API_KEY }}
project-id: ${{ env.ZAD_PROJECT_ID }}
component: ${{ env.ZAD_COMPONENT }}
image: ${{ needs.build.outputs.image }}
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ site
# IDE files
.idea/

# Claude Code
.claude/



.Rproj.user
Expand Down
4 changes: 2 additions & 2 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# See https://pre-commit.com/hooks.html for more hooks
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v6.0.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
Expand All @@ -12,7 +12,7 @@ repos:
- id: check-added-large-files
- id: check-merge-conflict
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.9
rev: v0.15.1
hooks:
- id: ruff
- id: ruff-format
Expand Down
16 changes: 12 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,27 @@ Dat kan op verschillende manieren. Zie onze

### Lokaal ontwikkelen

Het Algoritmekader project kan lokaal met behulp van [Python](https://www.python.org/) worden gedraaid. Installeer
hiervoor de benodigde packages in een [virtual environment](https://docs.python.org/3/library/venv.html):
Het Algoritmekader project kan lokaal worden gedraaid met [Python](https://www.python.org/) of met een container.

#### Met Python

Installeer de benodigde packages in een [virtual environment](https://docs.python.org/3/library/venv.html):

```bash
pip install -r requirements.txt
mkdocs serve
```

Vervolgens kun je een preview van het Algoritmekader bekijken:
#### Met Podman/Docker

Bouw en draai het Algoritmekader als container:

```bash
mkdocs serve
podman build -t algoritmekader -f container/Containerfile .
podman run -p 8080:8080 algoritmekader
```

Open vervolgens [http://localhost:8080](http://localhost:8080).

## Validatie Tools

Expand Down
Loading