Skip to content
Merged
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
15 changes: 15 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
.git
.github
node_modules
**/node_modules
.next
**/.next
out
build
coverage
*.tsbuildinfo
.env*.local
deploy
installer
tests
*.md
78 changes: 78 additions & 0 deletions .github/actions/deploy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: Uitrollen naar de server
description: Zet een image op de eigen server via SSH (zie deploy/README.nl.md). Slaat over met een waarschuwing als DEPLOY_HOST niet ingesteld is.

inputs:
environment:
description: qa, acc of production
required: true
image:
description: Volledige image-naam, bv. ghcr.io/dafkedd/projectx-eid@sha256:…
required: true
url:
description: Adres om na het uitrollen te controleren (vars.DEPLOY_URL)
required: false
host:
required: false
port:
required: false
user:
required: false
ssh-key:
required: false
known-hosts:
required: false
registry-token:
description: Token waarmee de server het image van ghcr.io haalt (github.token, alleen tijdens deze job geldig)
required: true

runs:
using: composite
steps:
- name: Uitrollen
shell: bash
env:
ENVIRONMENT: ${{ inputs.environment }}
IMAGE: ${{ inputs.image }}
DEPLOY_HOST: ${{ inputs.host }}
DEPLOY_PORT: ${{ inputs.port }}
DEPLOY_USER: ${{ inputs.user }}
DEPLOY_SSH_KEY: ${{ inputs.ssh-key }}
DEPLOY_KNOWN_HOSTS: ${{ inputs.known-hosts }}
REGISTRY_TOKEN: ${{ inputs.registry-token }}
run: |
if [ -z "$DEPLOY_HOST" ]; then
echo "::warning::Geen DEPLOY_HOST: $ENVIRONMENT niet uitgerold (zie deploy/README.nl.md)."
exit 0
fi
if [ -z "$DEPLOY_SSH_KEY" ] || [ -z "$DEPLOY_KNOWN_HOSTS" ]; then
echo "::error::DEPLOY_SSH_KEY en DEPLOY_KNOWN_HOSTS zijn nodig om naar $DEPLOY_HOST uit te rollen."
exit 1
fi
dir="$RUNNER_TEMP/ssh"
install -d -m 700 "$dir"
printf '%s\n' "$DEPLOY_SSH_KEY" > "$dir/key"
printf '%s\n' "$DEPLOY_KNOWN_HOSTS" > "$dir/known_hosts"
chmod 600 "$dir/key" "$dir/known_hosts"
# De server staat voor deze sleutel alleen "deploy <omgeving> <image>" toe; het token gaat via stdin.
printf '%s' "$REGISTRY_TOKEN" | ssh -i "$dir/key" -p "${DEPLOY_PORT:-22}" \
-o UserKnownHostsFile="$dir/known_hosts" -o StrictHostKeyChecking=yes -o BatchMode=yes \
-o ConnectTimeout=20 -o ServerAliveInterval=15 \
"${DEPLOY_USER:-deploy}@$DEPLOY_HOST" "deploy $ENVIRONMENT $IMAGE"
rm -rf "$dir"

- name: Controleren
if: inputs.url != '' && inputs.host != ''
shell: bash
env:
URL: ${{ inputs.url }}
run: |
for i in $(seq 1 20); do
if curl -fsS -o /dev/null --max-time 10 "$URL"; then
echo "OK: $URL"
echo "### ${{ inputs.environment }}: $URL" >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
sleep 6
done
echo "::error::$URL antwoordt niet na het uitrollen."
exit 1
83 changes: 80 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
check:
name: check (${{ matrix.os }}, Node ${{ matrix.node }})
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
Expand All @@ -38,15 +39,91 @@ jobs:
- run: npm test
- run: npm run build

setup:
name: setup (Windows)
runs-on: windows-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- run: npm ci
- name: Inno Setup klaarzetten
shell: pwsh
run: |
$iscc = @("${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe", "$env:ProgramFiles\Inno Setup 6\ISCC.exe") | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $iscc) {
choco install innosetup -y --no-progress
$iscc = @("${env:ProgramFiles(x86)}\Inno Setup 6\ISCC.exe", "$env:ProgramFiles\Inno Setup 6\ISCC.exe") | Where-Object { Test-Path $_ } | Select-Object -First 1
}
if (-not $iscc) { throw "ISCC.exe niet gevonden" }
"ISCC=$iscc" | Out-File -FilePath $env:GITHUB_ENV -Append -Encoding utf8
- run: npm run build:installer
- name: Setup testen (stil installeren, starten, verwijderen)
timeout-minutes: 10
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
$setup = (Resolve-Path "public\downloads\projectx-eid-setup.exe").Path
$dir = "$env:LOCALAPPDATA\DafkeDD\eid"
$exe = "$dir\dafke-eid.exe"
# Niet Start-Process -Wait: dat wacht ook op alle kindprocessen, en de bridge blijft draaien.
function RunAndWait([string]$file, [string[]]$arguments, [string]$what) {
$p = Start-Process $file -ArgumentList $arguments -PassThru
if (-not $p.WaitForExit(180000)) { throw "$what hangt" }
if ($p.ExitCode -ne 0) { throw "$what gaf code $($p.ExitCode)" }
}
function Status { try { (Invoke-RestMethod http://127.0.0.1:47820/v1/status -Headers @{ Origin = "http://localhost:3000" } -TimeoutSec 2).name } catch { $null } }

RunAndWait $setup @("/VERYSILENT", "/SUPPRESSMSGBOXES", "/NORESTART") "setup"
if (-not (Test-Path $exe)) { throw "Niet geïnstalleerd: $exe ontbreekt" }
Write-Host "Geïnstalleerd: dafke-eid $(& $exe --version)"
for ($i = 0; $i -lt 30 -and (Status) -ne "dafke-eid"; $i++) { Start-Sleep 1 }
if ((Status) -ne "dafke-eid") { throw "het programma draait niet na installeren" }
& $exe read --mock
if ($LASTEXITCODE -ne 0) { throw "dafke-eid read --mock mislukt" }

RunAndWait "$dir\unins000.exe" @("/VERYSILENT", "/SUPPRESSMSGBOXES") "verwijderen"
for ($i = 0; $i -lt 30 -and (Test-Path $exe); $i++) { Start-Sleep 1 }
if (Test-Path $exe) { throw "Na verwijderen staat $exe er nog" }
if (Status) { throw "het programma draait nog na verwijderen" }
- uses: actions/upload-artifact@v4
with:
name: windows-setup
path: |
public/downloads/projectx-eid-setup.exe
public/downloads/projectx-eid-setup.exe.sha256
if-no-files-found: error

# Het Docker-image voor QA, ACC en productie moet blijven bouwen (zie Dockerfile en deploy/).
docker:
name: docker image
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v4
- run: docker build -t projectx-eid:ci .
- name: Container starten en controleren
run: |
docker run -d --name projectx-ci -p 3000:3000 projectx-eid:ci
for i in $(seq 1 30); do
if curl -fsS -o /dev/null http://127.0.0.1:3000/; then echo "OK"; exit 0; fi
sleep 2
done
docker logs projectx-ci
exit 1

# Eén vaste naam om als vereiste check voor main in te stellen.
ci-check:
name: CI-check
if: always()
needs: [check]
needs: [check, setup, docker]
runs-on: ubuntu-latest
steps:
- run: |
if [ "${{ needs.check.result }}" != "success" ]; then
echo "check: ${{ needs.check.result }}"
echo "check: ${{ needs.check.result }}, setup: ${{ needs.setup.result }}, docker: ${{ needs.docker.result }}"
if [ "${{ needs.check.result }}" != "success" ] || [ "${{ needs.setup.result }}" != "success" ] || [ "${{ needs.docker.result }}" != "success" ]; then
exit 1
fi
130 changes: 106 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@ name: Release

# Alleen op de branch `release` (meestal een merge main → release). Stappen, zoals in Azure DevOps:
# 1. ci alle tests (ci.yml)
# 2. qa uitrollen naar QA (environment "qa")
# 3. acc uitrollen naar acceptatie (environment "acc")
# 4. release tag v<versie> + GitHub-release (environment "production")
# 2. image Docker-image bouwen (met de Windows-setup erin) en naar ghcr.io zetten
# 3. qa dat image uitrollen naar QA (environment "qa")
# 4. acc hetzelfde image naar acceptatie (environment "acc")
# 5. release hetzelfde image naar productie, tag v<versie> + GitHub-release met de Windows-setup
# (environment "production")
# Uitrollen gaat via SSH naar de eigen server (deploy/README.nl.md). Zonder secret DEPLOY_HOST wordt er
# niet uitgerold, alleen gewaarschuwd.
# Met "Required reviewers" op een environment wacht die stap op een knop "Approve" in het tabblad Actions.
# Bestaat tag v<versie> al, dan wordt er geen release gemaakt: verhoog eerst de versie (npm run version:patch).

Expand All @@ -23,49 +27,119 @@ jobs:
ci:
uses: ./.github/workflows/ci.yml

image:
name: Image
needs: ci
runs-on: ubuntu-latest
timeout-minutes: 20
permissions:
contents: read
packages: write
outputs:
image: ${{ steps.push.outputs.image }}
steps:
- uses: actions/checkout@v4
- name: Windows-setup ophalen (uit de CI-stap), voor de downloadknop in de app
uses: actions/download-artifact@v4
with:
name: windows-setup
path: public/downloads
- name: Bouwen en naar ghcr.io
id: push
env:
GH_TOKEN: ${{ github.token }}
run: |
repo="ghcr.io/${GITHUB_REPOSITORY,,}"
version=$(node -p "require('./package.json').version")
tag="$repo:$version-${GITHUB_SHA::7}"
echo "$GH_TOKEN" | docker login ghcr.io -u "$GITHUB_ACTOR" --password-stdin
docker build \
--label "org.opencontainers.image.source=$GITHUB_SERVER_URL/$GITHUB_REPOSITORY" \
--label "org.opencontainers.image.revision=$GITHUB_SHA" \
--label "org.opencontainers.image.version=$version" \
-t "$tag" -t "$repo:sha-$GITHUB_SHA" .
docker push "$tag"
docker push "$repo:sha-$GITHUB_SHA"
digest=$(docker inspect --format '{{index .RepoDigests 0}}' "$tag")
echo "image=$digest" >> "$GITHUB_OUTPUT"
echo "### Image: \`$tag\`" >> "$GITHUB_STEP_SUMMARY"

qa:
name: QA
needs: ci
needs: image
runs-on: ubuntu-latest
environment: qa
timeout-minutes: 15
environment:
name: qa
url: ${{ vars.DEPLOY_URL }}
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: ./.github/actions/deploy
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run build
# TODO: hier uitrollen naar de QA-omgeving (bv. Azure Web App, Vercel of een eigen server).
- run: echo "QA-build klaar voor ${GITHUB_SHA::7}. Uitrollen naar QA is nog niet ingesteld."
environment: qa
image: ${{ needs.image.outputs.image }}
url: ${{ vars.DEPLOY_URL }}
host: ${{ secrets.DEPLOY_HOST }}
port: ${{ secrets.DEPLOY_PORT }}
user: ${{ secrets.DEPLOY_USER }}
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}
known-hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
registry-token: ${{ github.token }}

acc:
name: ACC
needs: qa
needs: [image, qa]
runs-on: ubuntu-latest
environment: acc
timeout-minutes: 15
environment:
name: acc
url: ${{ vars.DEPLOY_URL }}
permissions:
contents: read
packages: read
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
- uses: ./.github/actions/deploy
with:
node-version: 22
cache: npm
- run: npm ci
- run: npm run build
# TODO: hier uitrollen naar de acceptatie-omgeving.
- run: echo "ACC-build klaar voor ${GITHUB_SHA::7}. Uitrollen naar ACC is nog niet ingesteld."
environment: acc
image: ${{ needs.image.outputs.image }}
url: ${{ vars.DEPLOY_URL }}
host: ${{ secrets.DEPLOY_HOST }}
port: ${{ secrets.DEPLOY_PORT }}
user: ${{ secrets.DEPLOY_USER }}
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}
known-hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
registry-token: ${{ github.token }}

release:
name: Release
needs: acc
needs: [image, acc]
runs-on: ubuntu-latest
environment: production
environment:
name: production
url: ${{ vars.DEPLOY_URL }}
permissions:
contents: write
packages: read
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Uitrollen naar productie
uses: ./.github/actions/deploy
with:
environment: production
image: ${{ needs.image.outputs.image }}
url: ${{ vars.DEPLOY_URL }}
host: ${{ secrets.DEPLOY_HOST }}
port: ${{ secrets.DEPLOY_PORT }}
user: ${{ secrets.DEPLOY_USER }}
ssh-key: ${{ secrets.DEPLOY_SSH_KEY }}
known-hosts: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
registry-token: ${{ github.token }}
- uses: actions/setup-node@v4
with:
node-version: 22
Expand All @@ -87,13 +161,21 @@ jobs:
name="projectx-eid-${{ steps.version.outputs.version }}"
git archive --format=zip --prefix="$name/" -o "$name.zip" HEAD
sha256sum "$name.zip" > "$name.zip.sha256"
- name: Windows-setup ophalen (uit de CI-stap)
if: steps.version.outputs.exists == 'false'
uses: actions/download-artifact@v4
with:
name: windows-setup
path: setup
- name: Release maken
if: steps.version.outputs.exists == 'false'
env:
GH_TOKEN: ${{ github.token }}
run: |
v="${{ steps.version.outputs.version }}"
gh release create "v$v" "projectx-eid-$v.zip" "projectx-eid-$v.zip.sha256" \
cp setup/projectx-eid-setup.exe "projectx-eid-setup-$v.exe"
(cd setup && sha256sum projectx-eid-setup.exe | sed "s/projectx-eid-setup.exe/projectx-eid-setup-$v.exe/") > "projectx-eid-setup-$v.exe.sha256"
gh release create "v$v" "projectx-eid-setup-$v.exe" "projectx-eid-setup-$v.exe.sha256" "projectx-eid-$v.zip" "projectx-eid-$v.zip.sha256" \
--target "$GITHUB_SHA" \
--title "ProjectX eID $v" \
--generate-notes
Loading
Loading