Skip to content

Set correct image name #1081

Set correct image name

Set correct image name #1081

Workflow file for this run

---
name: 'CI'
on:
push:
env:
NX_CLOUD_ACCESS_TOKEN: ${{ secrets.NX_CLOUD_ACCESS_TOKEN }}
NX_NO_CLOUD: ${{ vars.NX_NO_CLOUD }}
GITHUB_ACTIONS: true
jobs:
lint:
name: Lint Code
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup main branch for reference
if: ${{ github.ref_name != 'main' }}
run: git branch --track main origin/main
- name: Setup NX
uses: nrwl/nx-set-shas@v3
- name: Setup PNPM package manager
uses: pnpm/action-setup@v3
with:
version: 8
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Setup the BEAM and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: '26.2.2'
elixir-version: '1.16.1'
- name: Install node dependencies
run: pnpm install
- name: Lint
run: pnpm nx affected -t lint
- name: Typecheck
run: pnpm nx affected -t typecheck
tests:
name: Run tests
runs-on: ubuntu-latest
services:
postgres:
image: postgres:latest
ports:
- 5432:5432
options: >-
-e POSTGRES_USER=lotta
-e POSTGRES_PASSWORD=lotta
rabbitmq:
image: rabbitmq:latest
ports:
- 5672:5672
redis:
image: bitnami/redis:latest
ports:
- 6379:6379
options: >-
-e REDIS_PASSWORD=lotta
minio:
image: lazybit/minio
ports:
- 9000:9000
env:
MINIO_ACCESS_KEY: AKIAIOSFODNN7EXAMPLE
MINIO_SECRET_KEY: wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY
options: >-
--name minio
--health-cmd "curl http://localhost:9000/minio/health/live"
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup minio
run: >
docker run --network host --name minio_setup --entrypoint /bin/bash minio/mc -c "
/usr/bin/mc alias set minio http://localhost:9000 AKIAIOSFODNN7EXAMPLE wJalrXUtnFEMI/K7MDENG/bPxRfiCYEXAMPLEKEY;
/usr/bin/mc rm -r --force minio/lotta-dev-ugc;
/usr/bin/mc mb minio/lotta-dev-ugc;
/usr/bin/mc anonymous set download minio/lotta-dev-ugc;
exit 0;
"
- name: Setup main branch for reference
if: ${{ github.ref_name != 'main' }}
run: git branch --track main origin/main
- name: Setup NX
uses: nrwl/nx-set-shas@v3
- name: Setup PNPM package manager
uses: pnpm/action-setup@v3
with:
version: 8
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Setup the BEAM and Elixir
uses: erlef/setup-beam@v1
with:
otp-version: '26.2.2'
elixir-version: '1.16.1'
- name: Install npm dependencies
run: pnpm install
- name: Run Unit / Component tests
run: pnpm nx affected -t test --configuration=coverage
env:
NODE_ENV: test
MIX_ENV: test
- name: Run end-to-end tests
run: |
pnpm exec playwright install --with-deps chromium
pnpm nx affected -t e2e --configuration=ci
- name: Upload Tests for storybook-addon-theme
uses: codecov/codecov-action@v4
with:
directory: libs/storybook-addon-theme/coverage/
flags: storybook-addon-theme
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Upload Tests for hubert
uses: codecov/codecov-action@v4
with:
directory: libs/hubert/coverage/
flags: hubert
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Upload Tests for Webapp
uses: codecov/codecov-action@v4
with:
directory: apps/webapp/coverage/
flags: webapp
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
- name: Upload Tests for CoreApi
uses: codecov/codecov-action@v4
with:
directory: apps/core-api/cover/
flags: core-api
token: ${{ secrets.CODECOV_TOKEN }}
verbose: true
check-build:
name: Check the projects build
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup main branch for reference
if: ${{ github.ref_name != 'main' }}
run: git branch --track main origin/main
- name: Setup NX
uses: nrwl/nx-set-shas@v3
if: github.ref_name != 'main' && !contains(github.event.pull_request.labels.*.name, 'preview')
- name: Setup PNPM package manager
uses: pnpm/action-setup@v3
if: github.ref_name != 'main' && !contains(github.event.pull_request.labels.*.name, 'preview')
with:
version: 8
- name: Setup Node.js
if: github.ref_name != 'main' && !contains(github.event.pull_request.labels.*.name, 'preview')
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'pnpm'
- name: Setup the BEAM and Elixir
if: github.ref_name != 'main' && !contains(github.event.pull_request.labels.*.name, 'preview')
uses: erlef/setup-beam@v1
with:
otp-version: '26.2.2'
elixir-version: '1.16.1'
- name: Install npm dependencies
if: github.ref_name != 'main' && !contains(github.event.pull_request.labels.*.name, 'preview')
run: pnpm install
- name: Run build task
if: github.ref_name != 'main' && !contains(github.event.pull_request.labels.*.name, 'preview')
run: pnpm nx affected -t build
publish-docker-images:
name: ${{ matrix.image.name }} (${{ matrix.environment }}) Docker images
needs:
- check-build
- tests
- lint
strategy:
matrix:
environment: ['preview', 'staging']
image:
- name: ghcr.io/lotta-schule/web
dockerfile: apps/webapp/Dockerfile
context: .
- name: ghcr.io/lotta-schule/core
dockerfile: Dockerfile
context: apps/core-api
exclude:
- environment: ${{ github.ref_name == 'main' && 'preview' || 'staging' }}
uses: ./.github/workflows/__deploy_dockerfile.yaml
with:
name: ${{ matrix.image.name }}
tags: ${{ format(matrix.environment == 'preview' && '{1}:{0}' || '{1}:staging,{1}:{0},{1}:canary-{0}', github.sha, matrix.image.name) }}
releaseName: ${{ github.sha }}
context: ${{ matrix.image.context }}
dockerfile: ${{ matrix.image.dockerfile }}
platforms: |
linux/amd64
linux/arm64
push: ${{ contains(github.event.pull_request.labels.*.name, 'preview') || github.ref_name == 'main' }}
secrets:
password: ${{ secrets.GITHUB_TOKEN }}
sentry_auth_token: ${{ secrets.SENTRY_AUTH_TOKEN }}
sentry_dsn: ${{ secrets.SENTRY_DSN }}
create-sentry-release:
name: |
Sentry Rel.: ${{ matrix.project }} (${{ matrix.environment }})
if: contains(github.event.pull_request.labels.*.name, 'preview') || github.ref_name == 'main'
needs:
- publish-docker-images
strategy:
matrix:
environment: ['preview', 'staging']
project: ['core', 'web']
exclude:
- environment: ${{ github.ref_name == 'main' && 'preview' || 'staging' }}
runs-on: ubuntu-latest
steps:
# Sentry does need a repository it seems
- name: Checkout Repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ matrix.project }}
with:
environment: ${{ matrix.environment }}
version: ${{ github.sha }}