Skip to content

Commit

Permalink
Merge pull request #4130 from signalco-io/next
Browse files Browse the repository at this point in the history
Next
  • Loading branch information
AleksandarDev authored Dec 16, 2023
2 parents 42df9a8 + 6312d41 commit a32fc54
Show file tree
Hide file tree
Showing 116 changed files with 3,132 additions and 2,461 deletions.
30 changes: 17 additions & 13 deletions .github/workflows/cloud-deploy-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,19 @@
name: "[Cloud] Preview Deploy"

on:
pull_request:
branches:
- "main"
- "next"

env:
DOTNET_VERSION: "7.0.x" # set this to the dotnet version to use
workflow_call:
inputs:
baseRef:
required: true
type: string
description: "The base branch to deploy to"

defaults:
run:
working-directory: ./cloud/infrastructure

jobs:
build-and-deploy:
build-and-preview:
runs-on: ubuntu-latest
steps:
- name: "Checkout GitHub Action"
Expand All @@ -31,10 +30,10 @@ jobs:
npx mutex wait signalcocloudpreview
popd
- name: ✨ Setup DotNet ${{ env.DOTNET_VERSION }} Environment
- name: ✨ Setup DotNet
uses: actions/setup-dotnet@v4
with:
dotnet-version: ${{ env.DOTNET_VERSION }}
dotnet-version: "7.0.x"

- name: ✨ Setup pnpm
uses: pnpm/[email protected]
Expand All @@ -54,16 +53,21 @@ jobs:
- name: 🔎 Determine stack
shell: bash
run: |
[[ $(echo ${BASE_BRANCH#refs/heads/}) = "main" ]] && echo "##[set-output name=branch;]production" || echo "##[set-output name=branch;]$(echo ${BASE_BRANCH#refs/heads/})"
if [[ $(echo ${BASE_BRANCH#refs/heads/}) = "main" ]]
then
echo "stack=production" >> $GITHUB_OUTPUT
else
echo "stack=${BASE_BRANCH#refs/heads/}" >> $GITHUB_OUTPUT
fi
id: extract_branch
env:
BASE_BRANCH: ${{ github.base_ref }}
BASE_BRANCH: ${{ inputs.baseRef }}

- name: ⚡ Preview Deploy Infrastructure
uses: pulumi/actions@v4
with:
command: preview
stack-name: signalco/cloud-primary/${{ steps.extract_branch.outputs.branch }}
stack-name: signalco/cloud-primary/${{ steps.extract_branch.outputs.stack }}
work-dir: ./cloud/infrastructure
comment-on-pr: true
env:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/companions-maui-build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ jobs:
# Delete output directory
rm -r "artifacts"
- name: Upload artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: "artifact-${{ matrix.configuration }}"
path: "companion-maui-android-${{ matrix.configuration }}.zip"
6 changes: 3 additions & 3 deletions .github/workflows/global-codeql_analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
12 changes: 12 additions & 0 deletions .github/workflows/global-smart-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:
types: [opened, synchronize, reopened]

jobs:
# Mark PR as auto-mergeable if it's opened by known user
enable_auto_merge_for_known_users:
name: "[Global] Enable auto-merge for known users"
runs-on: ubuntu-latest
Expand All @@ -20,4 +21,15 @@ jobs:
gh pr comment ${{ github.event.pull_request.number }} --body "🪄 Auto-merge enabled for known user."
env:
GITHUB_TOKEN: ${{ secrets.AT_GH_CD_REPO_PAT }}
# Retarget to next branch if PR is opened against main (and head is not next)
retarget-feature-prs:
if: github.event_name == 'pull_request' && github.event.action == 'opened' && github.base_ref == 'main' && github.head_ref != 'next'
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎
uses: actions/checkout@v4
- name: Change PR target
run: gh pr edit ${{ github.event.number }} --base next
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

6 changes: 4 additions & 2 deletions .github/workflows/global-sync-next-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ on:
concurrency: merge_main

jobs:
merge-branch:
# When a PR is merged into main, attempt to merge main into next
sync-next-branch:
runs-on: ubuntu-latest
steps:
- name: Checkout 🛎
Expand All @@ -30,4 +31,5 @@ jobs:
if: steps.cpr.outputs.pr_created == 'true'
run: gh pr merge --merge --auto "${{ steps.cpr.outputs.pr_number }}"
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}

123 changes: 74 additions & 49 deletions .github/workflows/nextjs_bundle_analysis_reusable.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: 'NextJS Bundle Analysis'
name: '[Web] CI - Next.js'

on:
workflow_call:
Expand All @@ -17,64 +17,106 @@ on:
required: true
type: string
description: 'Path to the package or application to analzye'
vercelProjectId:
required: true
type: string
description: 'Vercel Project ID'

env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: signalco
TURBO_REMOTE_ONLY: true
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY: ${{ secrets.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY }}
CLERK_SECRET_KEY: ${{ secrets.CLERK_SECRET_KEY }}
DOPROCESS_DATABASE_HOST: ${{ secrets.DOPROCESS_DATABASE_HOST }}
DOPROCESS_DATABASE_USERNAME: ${{ secrets.DOPROCESS_DATABASE_USERNAME }}
DOPROCESS_DATABASE_PASSWORD: ${{ secrets.DOPROCESS_DATABASE_PASSWORD }}
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
VERCEL_PROJECT_ID: ${{ inputs.vercelProjectId }}
VERCEL_ORG_ID: team_Ade0MlfC3211ml3wYJZ4c9hn

defaults:
run:
working-directory: ./web

jobs:
analysis:
name: "[${{ inputs.name }}] Next.js Bundle Analysis"
ci:
timeout-minutes: 5
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}-${{ inputs.name }}
cancel-in-progress: true
group: ${{ github.workflow }}-${{ github.ref || github.run_id }}-${{ inputs.name }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Setup pnpm

- name: ✨ Setup pnpm
uses: pnpm/[email protected]
with:
version: 'latest'
- uses: actions/setup-node@v4

- name: ✨ Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "pnpm"
cache-dependency-path: ./web
- name: Install dependencies
cache-dependency-path: ./web/pnpm-lock.yaml

- name: 📦️ Install dependencies
run: pnpm install --frozen-lockfile --filter ${{ inputs.name }}... --filter .

- name: Build app
- name: 🔎 Lint app
if: success() && github.event_name == 'pull_request'
run: pnpm lint --filter=${{ inputs.name }}

- name: ✨ Setup Vercel CLI
run: pnpm install --global vercel@latest

- name: ⚙️ Pull Vercel Environment Information
run: vercel env pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
working-directory: ${{ inputs.path }}/

- name: ⚒️ Build app
run: pnpm build --filter=${{ inputs.name }}

- name: 📦️ Install playwright browsers
if: success() && github.event_name == 'pull_request'
run: |
pnpm install --global playwright
pnpm playwright install --with-deps
- name: ⚒️ Test app
if: success() && github.event_name == 'pull_request'
run: pnpm test --filter=${{ inputs.name }}

## TODO: Enable when stories-check is ready
# - name: Run stories-check
# run: pnpm stories-check
# id: runStoriesCheck
# continue-on-error: true
# working-directory: web/apps/web/
# - name: Commit changes
# id: ccc
# if: steps.runStoriesCheck.outcome == 'failure'
# uses: EndBug/add-and-commit@v9
# with:
# add: ".stories-approved"
# message: "[skip ci] [stories-check] Automated stories changes"
# new_branch: ${{ github.head_ref }}
# default_author: github_actions
# env:
# GITHUB_TOKEN: ${{ secrets.AT_GH_CD_REPO_PAT }}

# Here's the first place where next-bundle-analysis' own script is used
# This step pulls the raw bundle stats for the current bundle
- name: Analyze bundle
- name: 🔎 Analyze bundle
run: npx -yes -p github:hashicorp/nextjs-bundle-analysis report
working-directory: ${{ inputs.path }}/
- name: Upload bundle

- name: 🔼 Upload bundle
uses: actions/upload-artifact@v3
with:
name: bundle
path: ${{ inputs.path }}/.next/analyze/__bundle_analysis.json

- name: Download base branch bundle stats
uses: dawidd6/action-download-artifact@v2
if: success() && github.event.number
- name: 🔽 Download base branch bundle stats
uses: dawidd6/action-download-artifact@v3
if: success() && github.event_name == 'pull_request'
with:
workflow: ${{ inputs.workflowName }}
branch: ${{ github.event.pull_request.base.ref }}
Expand All @@ -93,42 +135,25 @@ jobs:
#
# Either of these arguments can be changed or removed by editing the `nextBundleAnalysis`
# entry in your package.json file.
- name: Compare with base branch bundle
if: success() && github.event.number
- name: 🔎 Compare with base branch bundle
if: success() && github.event_name == 'pull_request'
run: ls -laR .next/analyze/base && npx -yes -p github:hashicorp/nextjs-bundle-analysis compare
working-directory: ${{ inputs.path }}/

- name: Get comment body
- name: 💬 Get comment body
id: get-comment-body
if: success() && github.event.number
if: success() && github.event_name == 'pull_request'
uses: actions/github-script@v7
with:
result-encoding: string
script: |
const fs = require('fs')
const comment = fs.readFileSync('${{ inputs.path }}/.next/analyze/__bundle_analysis_comment.txt', 'utf8') + "<!-- __NEXTJS_BUNDLE_${{ inputs.name }} -->"
const comment = fs.readFileSync('${{ inputs.path }}/.next/analyze/__bundle_analysis_comment.txt', 'utf8')
core.setOutput('body', comment)
- name: Find Comment
uses: peter-evans/find-comment@v2
if: success() && github.event.number
id: fc
with:
issue-number: ${{ github.event.number }}
body-includes: '<!-- __NEXTJS_BUNDLE_${{ inputs.name }} -->'

- name: Create Comment
uses: peter-evans/[email protected]
if: success() && github.event.number && steps.fc.outputs.comment-id == 0
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.get-comment-body.outputs.body }}

- name: Update Comment
uses: peter-evans/[email protected]
if: success() && github.event.number && steps.fc.outputs.comment-id != 0
- name: 💬 Comment
uses: marocchino/sticky-pull-request-comment@v2
if: success() && steps.get-comment-body.outputs.body != ''
with:
issue-number: ${{ github.event.number }}
body: ${{ steps.get-comment-body.outputs.body }}
comment-id: ${{ steps.fc.outputs.comment-id }}
edit-mode: replace
header: next-touched-pages-${{ inputs.name }}
message: ${{ steps.get-comment-body.outputs.body }}
Loading

7 comments on commit a32fc54

@vercel
Copy link

@vercel vercel bot commented on a32fc54 Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on a32fc54 Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

signalco-slco – ./web/apps/slco

signalco-slco-git-main-signalco.vercel.app
signalco-slco.vercel.app
slco.io
signalco-slco-signalco.vercel.app
slco.signalco.io

@vercel
Copy link

@vercel vercel bot commented on a32fc54 Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on a32fc54 Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

signalco-ui-docs – ./web/apps/ui-docs

signalco-ui-docs.vercel.app
signalco-ui-docs-signalco.vercel.app
signalco-ui-docs-git-main-signalco.vercel.app
ui.signalco.io

@vercel
Copy link

@vercel vercel bot commented on a32fc54 Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

signalco-blog – ./web/apps/blog

signalco-blog.vercel.app
signalco-blog-signalco.vercel.app
signalco-blog-git-main-signalco.vercel.app
blog.signalco.io

@vercel
Copy link

@vercel vercel bot commented on a32fc54 Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

signalco-app – ./web/apps/app

signalco-app-signalco.vercel.app
signalco-app.vercel.app
signalco-app-git-main-signalco.vercel.app
app.signalco.io

@vercel
Copy link

@vercel vercel bot commented on a32fc54 Dec 16, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.