Added banner on cv spaces for scoutgame #1012
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: Websockets CI | |
on: | |
push: | |
branches: [main] | |
paths: | |
- '.cdk/**' | |
- 'docker-compose.yml' | |
- '.ebextensions/websockets/**' | |
- '.ebstalk.apps.env/websockets.env' | |
- '.github/actions/**' | |
- '.github/workflows/deploy_websockets.yml' | |
- 'package.json' | |
- 'package-lock.json' | |
- 'apps/websockets/**' | |
- 'adapters/**' | |
- 'config/**' | |
- 'lib/**' | |
pull_request: | |
types: [labeled, opened, synchronize] | |
branches: ['**'] | |
paths: | |
- '.cdk/**' | |
- 'docker-compose.yml' | |
- '.ebextensions/websockets/**' | |
- '.ebstalk.apps.env/websockets.env' | |
- '.github/actions/**' | |
- '.github/workflows/deploy_websockets.yml' | |
- 'package.json' | |
- 'package-lock.json' | |
- 'apps/websockets/**' | |
- 'adapters/**' | |
- 'config/**' | |
- 'lib/**' | |
# include some paths so that we trigger deploy for web app staging | |
- 'components/**' | |
- 'pages/**' | |
workflow_dispatch: | |
inputs: | |
core_pkg_version: | |
description: 'Core pkg version to update to' | |
required: true | |
concurrency: | |
group: ci-websockets-${{ github.event_name }}-${{ github.ref }} | |
jobs: | |
build: | |
name: Build Websockets | |
runs-on: ubuntu-latest | |
outputs: | |
head_commit_message: ${{ steps.setup_variables.outputs.commit_message }} | |
deploy_staging: ${{ steps.setup_variables.outputs.deploy_staging }} | |
skip_tests: ${{ steps.setup_variables.outputs.skip_tests }} | |
steps: | |
- name: Print Triggering event context payload | |
env: | |
workflow_event_context: ${{ toJSON(github.event) }} | |
run: | | |
echo "$workflow_event_context" | |
echo "Workflow and code ref: ${{github.ref}}" | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Setup variables | |
id: setup_variables | |
# source https://github.com/orgs/community/discussions/28474 | |
run: | | |
echo "commit_message=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT" | |
echo "deploy_staging=${{(github.event.action == 'labeled' && (github.event.label.name == ':rocket: deploy-websockets' || github.event.label.name == ':rocket: deploy')) || (github.event.action != 'labeled' && contains(github.event.pull_request.labels.*.name, ':rocket: deploy-websockets') || contains(github.event.pull_request.labels.*.name, ':rocket: deploy'))}}" >> $GITHUB_OUTPUT | |
echo "skip_tests=${{ contains(env.commit_message, 'skip-tests') }}" >> $GITHUB_OUTPUT | |
- name: Install dependencies | |
uses: ./.github/actions/install | |
with: | |
app_name: websockets | |
core_pkg_version: ${{ inputs.core_pkg_version }} | |
commit_core_pkg_upgrade: true | |
- name: Build app | |
uses: ./.github/actions/build_app | |
with: | |
app_name: websockets | |
test: | |
name: Test apps | |
runs-on: ubuntu-latest | |
needs: build | |
if: ${{ github.event.action != 'labeled' && needs.build.outputs.skip_tests != 'true' }} | |
# Postgres setup copied from https://gist.github.com/2color/537f8ef13ecec80059abb007839a6878 | |
services: | |
postgres: | |
image: postgres | |
env: | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
options: >- | |
--health-cmd pg_isready | |
--health-interval 10s | |
--health-timeout 5s | |
--health-retries 5 | |
--hostname postgres | |
ports: | |
# Maps tcp port 5432 on service container to the host | |
- 5432:5432 | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Restore dependencies from cache | |
uses: ./.github/actions/install | |
- name: Setup test database | |
run: npx dotenv -e .env.test.local -- npm run prisma:reset | |
- name: Restore app from cache | |
uses: ./.github/actions/build_app | |
with: | |
app_name: websockets | |
- name: Typecheck app | |
run: npm run typecheck -w apps/websockets | |
- name: Run eslint on changed files | |
uses: tj-actions/eslint-changed-files@v25 | |
with: | |
warn_ignored: 'true' | |
skip_annotations: 'true' # do not annotate code in the PR | |
file_extensions: '**/*.{ts,tsx}' | |
escape_paths: 'false' | |
- name: Run tests | |
run: npm run sockets:test | |
upload-docker: | |
name: Upload Docker image | |
runs-on: ubuntu-latest | |
# run whether previous jobs were successful or skipped | |
if: | | |
github.ref == 'refs/heads/main' || needs.build.outputs.deploy_staging == 'true' | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install dependencies | |
uses: ./.github/actions/install | |
- name: Restore app from cache | |
uses: ./.github/actions/build_app | |
with: | |
app_name: websockets | |
- name: Update Dockerfile | |
run: | | |
rm Dockerfile && mv apps/websockets/Dockerfile Dockerfile | |
- name: Build and Push Docker image | |
id: docker_build_push | |
uses: ./.github/actions/build_docker_image | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
AWS_REGION: us-east-1 | |
with: | |
ecr_registry: websockets | |
upload-static-assets: | |
name: Upload assets in production | |
runs-on: ubuntu-latest | |
# run whether previous jobs were successful or skipped | |
if: github.ref == 'refs/heads/main' && !(failure() || cancelled()) | |
needs: build | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install dependencies | |
uses: ./.github/actions/install | |
- name: Calculate Build ID | |
id: get_build_id | |
run: | | |
build_id=${{ hashFiles('package-lock.json', 'apps/websockets/*.[jt]s') }} | |
echo "build_id=$build_id" >> $GITHUB_OUTPUT | |
- name: Restore app from cache | |
uses: ./.github/actions/build_app | |
with: | |
app_name: websockets | |
- name: Upload JS source maps to Datadog | |
env: | |
DATADOG_API_KEY: ${{ secrets.DATADOG_API_KEY }} | |
run: | | |
npm install -g @datadog/datadog-ci | |
datadog-ci sourcemaps upload apps/websockets/dist \ | |
--service=websockets \ | |
--release-version=${{ steps.get_build_id.outputs.build_id }} \ | |
--minified-path-prefix=https://cdn.charmverse.io/_next/static | |
deploy-production: | |
name: Deploy to production | |
# run whether previous jobs were successful or skipped | |
if: github.ref == 'refs/heads/main' && !(failure() || cancelled()) | |
needs: [test, upload-docker, upload-static-assets] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
# - name: Package websockets | |
# id: pkg_websocket | |
# run: | | |
# rm -r .ebextensions && mv .ebextensions_tmp/websockets .ebextensions | |
# cat files_to_zip.txt | zip --symlinks -r@ deploy_websockets.zip | |
# changed_files=$(git diff --name-only ${{github.event.before}} ${{github.event.after}}) | |
# websocket_src_file_pattern='^(background/|config/|[dD]ocker|esbuild|lib/|package|next|tsconfig|components/common/CharmEditor/components)+' | |
# for file in $changed_files; do | |
# echo "evaluating $file:" | |
# if [[ $file =~ $websocket_src_file_pattern ]]; then | |
# echo "Requires deployment to websocket" | |
# echo "deploy_websocket=true" >> $GITHUB_OUTPUT | |
# break | |
# fi | |
# done | |
- uses: ./.github/actions/deploy_production | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
with: | |
app_name: websockets | |
stack: prd-websockets | |
deploy-staging: | |
name: Deploy to staging | |
if: needs.build.outputs.deploy_staging == 'true' | |
runs-on: ubuntu-latest | |
# prevent staging deploys + cleanup running in parallel | |
concurrency: staging-${{ github.ref }} | |
needs: [build, upload-docker] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ./.github/actions/deploy_staging | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
with: | |
app_name: websockets | |
discord-alert: | |
name: Notify Discord of failure | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' && failure() | |
# pass in all steps so we can check if any failed | |
needs: [test, upload-docker, upload-static-assets, deploy-production] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Notify Discord | |
uses: ./.github/actions/notify_error | |
env: | |
DISCORD_WARNINGS_WEBHOOK: ${{ secrets.DISCORD_WARNINGS_WEBHOOK }} | |
with: | |
app_name: websockets |