Files
SlpSoftware/.gitea/workflows/continuous_integration.yaml
T

129 lines
3.5 KiB
YAML

name: Continuous Integration
on:
workflow_dispatch: {}
pull_request:
types: [opened, synchronize, reopened]
push:
branches: [master]
# Herbruikbare instellingen voor deze workflow. Pas deze aan op één plek als
# de Node/pnpm-versie wijzigt. Let op: de env-context is NIET beschikbaar in
# de `with:`-inputs van een aangeroepen reusable workflow (zie de deploy-test
# job hieronder), dat is een beperking van GitHub/Gitea Actions zelf, dus
# ARTIFACT_NAME/DEPLOY_ENVIRONMENT/DEPLOY_PATH blijven daar noodgedwongen
# letterlijk in de `with:`-sectie staan.
env:
NODE_VERSION: '20'
PNPM_VERSION: '9'
jobs:
prepare:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Get pnpm store directory
id: pnpm-store
run: echo "path=$(pnpm store path)" >> "$GITHUB_OUTPUT"
- name: Cache pnpm store
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
build:
needs: prepare
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Get pnpm store directory
id: pnpm-store
run: echo "path=$(pnpm store path)" >> "$GITHUB_OUTPUT"
- name: Restore pnpm store
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build
run: pnpm run build
- name: Upload build artifact
uses: actions/upload-artifact@v3
with:
name: dist
path: dist/
retention-days: 1
test:
needs: build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
- uses: pnpm/action-setup@v4
with:
version: ${{ env.PNPM_VERSION }}
- name: Get pnpm store directory
id: pnpm-store
run: echo "path=$(pnpm store path)" >> "$GITHUB_OUTPUT"
- name: Restore pnpm store
uses: actions/cache@v4
with:
path: ${{ steps.pnpm-store.outputs.path }}
key: pnpm-${{ hashFiles('pnpm-lock.yaml') }}
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Lint
run: pnpm run lint
- name: Unit tests
run: pnpm run test
deploy-test:
needs: [build, test]
if: github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/master')
uses: ./.gitea/workflows/deploy.yaml
secrets: inherit
# Let op: deze waarden kunnen hier NIET via het `env:`-blok bovenaan dit
# bestand worden gezet - de env-context is niet beschikbaar in de
# `with:`-sectie van een aangeroepen reusable workflow (beperking van
# GitHub/Gitea Actions zelf). Pas deze waarden dus rechtstreeks hier aan.
with:
artifact_name: dist
environment: test
deploy_path: /html/test/slpsoftware