Bug/1867 session close #1193
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: CI | |
on: | |
pull_request: | |
push: | |
branches: [main] | |
tags: ["**"] | |
workflow_dispatch: | |
jobs: | |
build: | |
name: Build and test | |
runs-on: ubuntu-latest | |
env: | |
EMAIL_RATE_LIMIT: 3600 | |
MATCHER_MAX_CAPACITY: 80 | |
MYSQL_DATABASE: test_econ | |
MYSQL_ROOT_PASSWORD: password | |
services: | |
database-root: | |
image: mariadb:10.6 | |
env: | |
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }} | |
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }} | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
database-tenant: | |
image: mariadb:10.6 | |
env: | |
MYSQL_DATABASE: ${{ env.MYSQL_DATABASE }} | |
MYSQL_ROOT_PASSWORD: ${{ env.MYSQL_ROOT_PASSWORD }} | |
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Build and test with Docker | |
uses: addnab/docker-run-action@v3 | |
env: | |
DATABASE_URL: mariadb://root:${{ env.MYSQL_ROOT_PASSWORD }}@database-root:3306/${{ env.MYSQL_DATABASE }} | |
DATABASE_URL_TENANT_TEST: mariadb://root:${{ env.MYSQL_ROOT_PASSWORD }}@database-tenant:3306/${{ env.MYSQL_DATABASE }} | |
SIHL_ENV: test | |
SMTP_SENDER: [email protected] | |
TEST_EMAIL: [email protected] | |
with: | |
image: ocaml/opam:debian-10-ocaml-4.14 | |
options: -v ${{ github.workspace }}:/app -w /app -e DATABASE_URL -e DATABASE_URL_TENANT_TEST -e TEST_EMAIL -e SMTP_SENDER -e SIHL_ENV | |
run: | | |
# Reclaim required directory permissions | |
sudo chown -R opam . | |
# Build and test executable | |
/app/scripts/build.sh || exit 1 | |
# Restore directory permissions to avoid conflicts | |
sudo chown -R 1001:123 . | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: run.exe | |
path: _build/default/pool/run/run.exe | |
- uses: actions/upload-artifact@v3 | |
if: failure() | |
with: | |
name: tests | |
path: _build/default/pool/test/ | |
- name: Notify about failure | |
if: failure() | |
uses: ./.github/actions/notify-failure | |
with: | |
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }} | |
assets: | |
name: Build assets | |
if: github.repository == 'uzh/pool' | |
runs-on: ubuntu-latest | |
container: | |
image: node:lts | |
env: | |
ECON_PACKAGE_REGISTRY_READ_TOKEN: ${{ secrets.ECON_PACKAGE_REGISTRY_READ_TOKEN }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: install yarn packages | |
run: yarn install | |
- name: build yarn package | |
run: yarn build | |
- name: move all assets to one folder | |
run: '[ "$(ls pool/public)" ] && cp -r pool/public/* public || exit 0' | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: assets | |
path: public | |
- name: Notify about failure | |
if: failure() | |
uses: ./.github/actions/notify-failure | |
with: | |
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }} | |
deploy_staging: | |
name: Trigger staging deploy | |
runs-on: ubuntu-latest | |
needs: [build, assets] | |
if: github.ref_name == 'main' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Trigger deploy | |
uses: ./.github/actions/trigger-deploy | |
with: | |
url: ${{ secrets.ECON_DEPLOY_TRIGGER_URL }} | |
token: ${{ secrets.ECON_DEPLOY_TRIGGER_TOKEN }} | |
release: | |
name: Release a new version | |
runs-on: ubuntu-latest | |
needs: [build, assets] | |
if: github.ref_type == 'tag' | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v3 | |
- name: Extract version changelog | |
run: sed -nr "/^## .?v?${GITHUB_REF_NAME}/,/^## /p" CHANGELOG.md | sed '1d;2d;$d' > changes.md | |
- name: Compress assets | |
run: | | |
tar -zcf assets.tar.gz assets | |
tar -zcf executable.tar.gz run.exe/run.exe | |
- name: Create release | |
uses: softprops/action-gh-release@v1 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
body_path: changes.md | |
files: | | |
assets.tar.gz | |
executable.tar.gz | |
- name: Notify about failure | |
if: failure() | |
uses: ./.github/actions/notify-failure | |
with: | |
webhook: ${{ secrets.ECON_TEAMS_WEBHOOK }} | |
deploy_production: | |
name: Trigger production deploy | |
runs-on: ubuntu-latest | |
needs: release | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Trigger deploy | |
uses: ./.github/actions/trigger-deploy | |
with: | |
url: ${{ secrets.ECON_DEPLOY_TRIGGER_URL }} | |
token: ${{ secrets.ECON_DEPLOY_TRIGGER_TOKEN }} | |
target: production |