From 44ce3ce54c016c6f6725382cb5f9edb15d542dd7 Mon Sep 17 00:00:00 2001 From: Ludovic Muller Date: Tue, 12 Dec 2023 18:44:12 +0100 Subject: [PATCH 1/5] docker: use node 20 --- Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index 7b2ef03..043f4a3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM docker.io/library/node:18-alpine +FROM docker.io/library/node:20-alpine # some default values ENV DATASET_BASE_URL="" From d2c72bf359be81f409a688540d13f8c4ed4ab7e0 Mon Sep 17 00:00:00 2001 From: Ludovic Muller Date: Tue, 12 Dec 2023 18:51:15 +0100 Subject: [PATCH 2/5] add CODEOWNERS --- .github/CODEOWNERS | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 .github/CODEOWNERS diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..a8f0c16 --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,17 @@ +# Configuration of GitHub Actions +.github/ @ludovicm67 + +# Trifid plugins +plugins/ @ludovicm67 + +# Configuration files for Trifid +config.yaml @ludovicm67 +config.local.yaml @ludovicm67 + +# Docker configuration +.dockerignore @ludovicm67 +Dockerfile @ludovicm67 + +# Dependencies +package.json @ludovicm67 +package-lock.json @ludovicm67 From f2123dfc71041ccfd47c1f10d3841defeca50e3b Mon Sep 17 00:00:00 2001 From: Ludovic Muller Date: Tue, 12 Dec 2023 18:53:08 +0100 Subject: [PATCH 3/5] chore: include other files --- .github/CODEOWNERS | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index a8f0c16..7a19a58 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -15,3 +15,8 @@ Dockerfile @ludovicm67 # Dependencies package.json @ludovicm67 package-lock.json @ludovicm67 + +# Other files +.editorconfig @ludovicm67 +.eslintrc.js @ludovicm67 +.gitignore @ludovicm67 From 6388604511949d14cd26302dc78cef9f20fc0405 Mon Sep 17 00:00:00 2001 From: Ludovic Muller Date: Wed, 13 Dec 2023 13:31:14 +0100 Subject: [PATCH 4/5] docs: prepare some changes --- README.md | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 3154708..24c362d 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ This provides a server for the domain [lindas.admin.ch](https://lindas.admin.ch) ## Purpose - Website of lindas.admin.ch -- Dereferencing of https://lindas.admin.ch/* and https://ld.admin.ch/* +- Dereferencing of `https://lindas.admin.ch/*` and `https://ld.admin.ch/*` ## Local deployment @@ -27,7 +27,6 @@ Simple changes can be done through clicking on the (c) symbol on the bottom of t The web pages are in [./views](/views) defined with and need to be referenced themselfs in the Routing below. Best is to copy a basic site (e.g. [publish.html](/views/publish.html)) to start a new web page. The web pages themself do refer in the code for the content to the multilingual versions of Markdown formated files in [./content](/content). (It is important to use the same name for the _.html and _.md similar that the link from (c) works.) -) The paths and the menu is specified in [./config.json](config.json): @@ -53,12 +52,12 @@ If something needs to be deployed quickly on PROD, there is no need to go throug ### Test -Every commit to `develop` branch creates a new `test_` container image in the project [gitlab registry](https://gitlab.ldbar.ch/zazuko/lindas-admin-ch/container_registry/). +Every commit to `develop` branch creates a new `test_` container image. The [gitops-main](https://gitlab.ldbar.ch/vshn/gitops-main) detects new images and deploys them automatically to https://test.lindas.admin.ch. ### Integration -Every commit to `main` branch creates a new `int_` container image in the project [gitlab registry](https://gitlab.ldbar.ch/zazuko/lindas-admin-ch/container_registry/). +Every commit to `main` branch creates a new `int_` container image. The [gitops-main](https://gitlab.ldbar.ch/vshn/gitops-main) detects new images and deploys them automatically to https://int.lindas.admin.ch. ### Production From 0fdf1f724793de0a4e20b642ed66d0e0d18fa337 Mon Sep 17 00:00:00 2001 From: Ludovic Muller Date: Wed, 13 Dec 2023 13:32:01 +0100 Subject: [PATCH 5/5] ci: configure GitHub Actions --- .github/workflows/ci.yaml | 156 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 156 insertions(+) create mode 100644 .github/workflows/ci.yaml diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml new file mode 100644 index 0000000..155636c --- /dev/null +++ b/.github/workflows/ci.yaml @@ -0,0 +1,156 @@ +name: CI Workflow + +on: + push: # Trigger on push to any branch for tests + workflow_dispatch: # Allow manual trigger for build-prod job + +jobs: + # Run tests + test: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Node.js + uses: actions/setup-node@v3 + with: + node-version: 20 + + - name: Install Dependencies + run: npm ci + + - name: Run Tests + run: npm run test + + # Build TEST environment (push on develop branch) + build-test: + if: github.ref == 'refs/heads/develop' + needs: test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create custom Docker tag + id: docker_tag + run: echo "tag=test_$(date '+%Y-%m-%d_%H%M%S')" >> "$GITHUB_OUTPUT" + + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: ${{ steps.docker_tag.outputs.tag }} + + - name: Build and push Docker image + id: docker_build + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} + platforms: | + linux/amd64 + cache-from: type=gha + cache-to: type=gha,mode=max + + # Build INT environment (push on main branch) + build-int: + if: github.ref == 'refs/heads/main' + needs: test + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create custom Docker tag + id: docker_tag + run: echo "tag=int_$(date '+%Y-%m-%d_%H%M%S')" >> "$GITHUB_OUTPUT" + + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: ${{ steps.docker_tag.outputs.tag }} + + - name: Build and push Docker image + id: docker_build + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} + platforms: | + linux/amd64 + cache-from: type=gha + cache-to: type=gha,mode=max + + # Build PROD environment (manual trigger for main branch) + build-prod: + if: github.ref == 'refs/heads/main' && github.event_name == 'workflow_dispatch' + needs: build-int + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + + - name: Login to GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Create custom Docker tag + id: docker_tag + run: echo "tag=prod_$(date '+%Y-%m-%d_%H%M%S')" >> "$GITHUB_OUTPUT" + + - name: Docker meta + id: docker_meta + uses: docker/metadata-action@v5 + with: + images: ghcr.io/${{ github.repository }} + tags: ${{ steps.docker_tag.outputs.tag }} + + - name: Build and push Docker image + id: docker_build + uses: docker/build-push-action@v5 + with: + context: . + file: ./Dockerfile + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.docker_meta.outputs.tags }} + labels: ${{ steps.docker_meta.outputs.labels }} + platforms: | + linux/amd64 + cache-from: type=gha + cache-to: type=gha,mode=max