Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Configure CI for develop branch #5

Merged
merged 5 commits into from
Dec 13, 2023
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
22 changes: 22 additions & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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

# Other files
.editorconfig @ludovicm67
.eslintrc.js @ludovicm67
.gitignore @ludovicm67
156 changes: 156 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -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=""
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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):

Expand All @@ -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_<date_time>` 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_<date_time>` 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_<date_time>` 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_<date_time>` 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
Expand Down