Skip to content

build: updates

build: updates #108

# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions
name: Build, Test & Release
on:
push:
branches: ['main', 'develop']
pull_request:
branches: ['main', 'develop']
jobs:
buildAndTest:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [16.x, 18.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
env:
# Persistent Rita
MYSQL_DATABASE: prita
MYSQL_HOST: localhost
MYSQL_USER: root
MYSQL_PASSWORD: root
PSQL_DATABASE: postgres
PSQL_HOST: localhost
PSQL_USER: postgres
PSQL_PASSWORD: postgres
# Rita Http
PORT: 3000
LOGLEVEL: info
DB_TYPE: POSTGRES
DB_HOST: localhost
DB_PORT: 5432
DB_USERNAME: postgres
DB_PASSWORD: postgres
DB_DATABASE: postgres
# Service containers to run with `container-job`
services:
# Label used to access the service container
postgres:
# Docker Hub image
image: postgres
# Provide the password for postgres
env:
POSTGRES_PASSWORD: postgres
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
# Maps tcp port 5432 on service container to the host
- 5432:5432
mysql:
image: mysql:5.7
env:
MYSQL_DATABASE: prita
MYSQL_ROOT_PASSWORD: root
ports:
- 3306:3306
options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
- name: Cache Rush
uses: actions/cache@v3
with:
path: |
common/temp/install-run
~/.rush
key: ${{ runner.os }}-${{ hashFiles('rush.json') }}
- name: Cache pnpm
uses: actions/cache@v3
with:
path: |
common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Install
run: node common/scripts/install-run-rush.js install
- name: Build and test
run: node common/scripts/install-run-rush.js build-and-test --verbose
# licenses:
# runs-on: ubuntu-latest
# if: github.event_name != 'pull_request'
# steps:
# - uses: actions/checkout@v3
# - uses: actions/setup-node@v3
# - name: Cache Rush
# uses: actions/cache@v3
# with:
# path: |
# common/temp/install-run
# ~/.rush
# key: ${{ runner.os }}-${{ hashFiles('rush.json') }}
# - name: Cache pnpm
# uses: actions/cache@v3
# with:
# path: |
# common/temp/pnpm-store
# key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
# - name: Install dependencies
# run: node common/scripts/install-run-rush.js install
# - name: FOSSA Scan
# uses: fossas/fossa-action@main
# with:
# api-key: ${{secrets.FOSSA_API_TOKEN}}
# - name: 'Run FOSSA Test'
# uses: fossas/fossa-action@main
# with:
# api-key: ${{secrets.FOSSA_API_TOKEN}}
# run-tests: true
release:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
runs-on: ubuntu-latest
needs: [buildAndTest]
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-node@v3
- name: Cache Rush
uses: actions/cache@v3
with:
path: |
common/temp/install-run
~/.rush
key: ${{ runner.os }}-${{ hashFiles('rush.json') }}
- name: Cache pnpm
uses: actions/cache@v3
with:
path: |
common/temp/pnpm-store
key: ${{ runner.os }}-${{ hashFiles('common/config/rush/pnpm-lock.yaml') }}
- name: Setup git
run: |
git config user.name 'github-actions[bot]'
git config user.email 'github-actions[bot]@users.noreply.github.com'
- name: Install
run: node common/scripts/install-run-rush.js install
- name: Build
run: node common/scripts/install-run-rush.js build
- name: Bump version
run: node common/scripts/install-run-rush.js version --bump --version-policy "rita-publish"
- name: Generate documentation
run: node common/scripts/install-run-rush.js generate-documentation
- run: node common/scripts/install-run-rush.js update
- run: git add .
- name: Commit changes
run: |
git commit -a -m 'chore: bump version and generate documentation' || echo "No changes to commit"
git push --follow-tags
- name: Rebase
run: |
git branch
git checkout develop
git pull
git rebase main
git push --follow-tags
- name: Publish to NPM
run: node common/scripts/install-run-rush.js publish -p --include-all --version-policy "rita-publish" --set-access-level=public
env:
NPM_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
buildDocker:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: [release]
uses: ./.github/workflows/docker.yml
githubPackages:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: [release]
uses: ./.github/workflows/github_packages.yml
deploy:
if: github.ref == 'refs/heads/main' && github.event_name != 'pull_request'
needs: [release]
uses: ./.github/workflows/deploy.yml
secrets: inherit