Bump @types/mocha from 10.0.7 to 10.0.8 in /Server #252
Workflow file for this run
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: | |
push: | |
paths: | |
- '**' | |
branches: | |
- '**' | |
tags: | |
- '*.*.*' | |
workflow_dispatch: | |
env: | |
ARTIFACT_NAME: live-chat | |
DOCKER_IMAGE_NAME: livechat | |
DOCKER_REGISTRY_DOMAIN: ghcr.io | |
jobs: | |
client: | |
name: Client | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- name: Validate HTML | |
uses: Cyb3r-Jak3/html5validator-action@v7.2.0 | |
with: | |
root: Client | |
css: true | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_NAME }}-client | |
path: Client | |
server: | |
name: Server | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
services: | |
mongodb: | |
image: mongo:6-jammy | |
env: | |
MONGO_INITDB_ROOT_USERNAME: mongodb | |
MONGO_INITDB_ROOT_PASSWORD: P4ssw0rd | |
MONGO_INITDB_DATABASE: github-actions-workflow | |
ports: | |
- 27017:27017 | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Install dependencies | |
working-directory: Server | |
run: npm install | |
- name: Build project | |
working-directory: Server | |
run: npm run build | |
- name: Generate Express session secret | |
id: express | |
run: echo "EXPRESS_SESSION_SECRET=$(openssl rand -hex 16)" >> $GITHUB_OUTPUT | |
- name: Create environment variables file | |
working-directory: Server | |
run: cp --verbose --archive production.env test.env | |
- name: Run tests | |
working-directory: Server | |
env: | |
NODE_ENV: test | |
HTTP_SERVER_ADDRESS: 127.0.0.1 | |
MONGO_SCHEME: mongodb | |
MONGO_HOST: 127.0.0.1 | |
MONGO_DATABASE: github-actions-workflow | |
MONGO_USER_NAME: mongodb | |
MONGO_USER_PASS: P4ssw0rd | |
EXPRESS_SESSION_SECRET: ${{ steps.express.outputs.EXPRESS_SESSION_SECRET }} | |
EXPRESS_CLIENT_DIRECTORY: ../Client | |
EXPRESS_COOKIE_DOMAIN: 127.0.0.1 | |
run: npm test | |
- name: Remove tests | |
working-directory: Server | |
run: rm --verbose --recursive dist/tests | |
- name: Upload log artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_NAME }}-server-log | |
path: Server/logs/server.log | |
- name: Upload build artifact | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_NAME }}-server | |
path: | | |
Server/dist/ | |
Server/package.json | |
Server/package-lock.json | |
Server/production.env | |
docker: | |
name: Docker | |
runs-on: ubuntu-22.04 | |
needs: | |
- client | |
- server | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.job }}-${{ github.ref }} | |
cancel-in-progress: false | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Clone repository | |
uses: actions/checkout@v4 | |
- name: Setup QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Setup Docker | |
uses: docker/setup-buildx-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
- name: Login to GitHub Container Registry | |
if: ${{ github.event_name != 'pull_request' && !startsWith( github.ref_name, 'dependabot/' ) }} | |
uses: docker/login-action@v3 | |
with: | |
registry: ${{ env.DOCKER_REGISTRY_DOMAIN }} | |
username: ${{ github.repository_owner }} | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Download server build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_NAME }}-server | |
path: artifacts/server/ | |
- name: Download client build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_NAME }}-client | |
path: artifacts/client/ | |
- name: Create metadata for Docker image | |
id: metadata | |
uses: docker/metadata-action@v5 | |
with: | |
images: ${{ env.DOCKER_REGISTRY_DOMAIN }}/${{ github.repository_owner }}/${{ env.DOCKER_IMAGE_NAME }} | |
flavor: latest=true | |
tags: | | |
type=ref,event=pr | |
type=ref,event=branch | |
type=semver,pattern={{major}} | |
type=semver,pattern={{major}}.{{minor}} | |
type=semver,pattern={{major}}.{{minor}}.{{patch}} | |
labels: | | |
org.opencontainers.image.title=Live Chat | |
org.opencontainers.image.vendor=${{ github.repository_owner }} | |
com.docker.extension.publisher-url=https://viral32111.com | |
- name: Build & push Docker image | |
uses: docker/build-push-action@v6 | |
with: | |
push: ${{ github.event_name != 'pull_request' && !startsWith( github.ref_name, 'dependabot/' ) }} | |
file: Dockerfile | |
context: artifacts | |
tags: ${{ steps.metadata.outputs.tags }} | |
labels: ${{ steps.metadata.outputs.labels }} | |
platforms: linux/amd64,linux/arm64 | |
provenance: false | |
no-cache: true | |
pull: true | |
- name: Delete untagged Docker images | |
if: ${{ github.event_name != 'pull_request' && !startsWith( github.ref_name, 'dependabot/' ) }} | |
uses: snok/container-retention-policy@v2 | |
with: | |
image-names: ${{ env.DOCKER_IMAGE_NAME }} | |
cut-off: 24 hours ago UTC | |
keep-at-least: 1 | |
untagged-only: true | |
skip-tags: latest | |
account-type: personal | |
token: ${{ secrets.PACKAGES_PERSONAL_ACCESS_TOKEN }} | |
deploy-github: | |
name: Deploy to GitHub Pages | |
runs-on: ubuntu-22.04 | |
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }} | |
needs: client | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
concurrency: | |
group: github-pages | |
cancel-in-progress: false | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
steps: | |
- name: Setup GitHub Pages | |
uses: actions/configure-pages@v5 | |
- name: Download client build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: ${{ env.ARTIFACT_NAME }}-client | |
path: artifact | |
- name: Upload to GitHub Pages | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: artifact | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 | |
- name: Run Page Speed Insights | |
uses: jakepartusch/psi-action@v1.3 | |
with: | |
url: ${{ steps.deployment.outputs.page_url }} | |
threshold: 70 | |
strategy: desktop | |
key: ${{ secrets.GOOGLE_PAGE_SPEED_INSIGHTS_API_KEY }} |