From a939ab8b41120eff3d6692a9b98c2a60c7df531a Mon Sep 17 00:00:00 2001 From: Dustin Brickwood Date: Thu, 21 Mar 2024 18:04:03 -0500 Subject: [PATCH] feat: adds deploy pipeline and addresses linting issues --- .firebaserc | 14 ++- .github/workflows/checks.yaml | 55 +++++++---- .github/workflows/deploy-preview.yml | 30 ++++++ .github/workflows/deploy-prod.yml | 56 +++++++++++ .github/workflows/deploy-staging.yml | 30 ++++++ .github/workflows/firebase-hosting-merge.yml | 20 ---- .../firebase-hosting-pull-request.yml | 21 ----- .github/workflows/secrets_scanner.yaml | 4 +- app.vue | 6 +- bun.lockb | Bin 603003 -> 617184 bytes .../{Footer.vue => FooterComponent.vue} | 0 .../{Header.vue => HeaderComponent.vue} | 0 firebase.json | 31 +++++- nuxt.config.ts | 6 -- package.json | 5 +- pages/about-us.vue | 2 +- pages/index.vue | 2 +- public/404.html | 33 ------- public/index.html | 89 ------------------ 19 files changed, 203 insertions(+), 201 deletions(-) create mode 100644 .github/workflows/deploy-preview.yml create mode 100644 .github/workflows/deploy-prod.yml create mode 100644 .github/workflows/deploy-staging.yml delete mode 100644 .github/workflows/firebase-hosting-merge.yml delete mode 100644 .github/workflows/firebase-hosting-pull-request.yml rename components/{Footer.vue => FooterComponent.vue} (100%) rename components/{Header.vue => HeaderComponent.vue} (100%) delete mode 100644 public/404.html delete mode 100644 public/index.html diff --git a/.firebaserc b/.firebaserc index 22c8cdce..22382211 100644 --- a/.firebaserc +++ b/.firebaserc @@ -1,5 +1,17 @@ { "projects": { - "default": "zksync-docs-staging" + "default": "zksync-docs" + }, + "targets": { + "zksync-docs": { + "hosting": { + "prod": [ + "zksync-docs" + ], + "staging": [ + "zksync-docs-staging" + ] + } + } } } diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index b8862165..766328ec 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -3,39 +3,54 @@ name: clean ๐Ÿงน on: pull_request: branches: [main, staging] - workflow_dispatch: jobs: - format: - name: format + setup: + name: Setup Environment runs-on: ubuntu-latest + outputs: + cache-key: ${{ steps.cache-keys.outputs.key }} steps: - uses: actions/checkout@v4 - uses: oven-sh/setup-bun@v1 - - name: Runs prettier formatter - run: | - bun install - bun run lint:prettier + - name: Install Dependencies + run: bun install + - id: cache-keys + run: echo "::set-output name=key::$(bun hash **/*.lock)" + + format: + name: Format Code + needs: setup + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Runs Prettier Formatter + run: bun run lint:prettier spelling: - name: spelling + name: Check Spelling + needs: setup runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v1 - - name: Runs cspell spell checker - run: | - bun install - bun run lint:spelling + - name: Runs cSpell Spell Checker + run: bun run lint:spelling - lint: - name: lint markdown + markdown-lint: + name: Lint Markdown + needs: setup runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: oven-sh/setup-bun@v1 - - name: Runs mdl markdown linter - run: | - bun install - bun run lint:markdown \ No newline at end of file + - name: Runs Markdown Linter + run: bun run lint:markdown + + eslint: + name: Lint Code + needs: setup + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - name: Runs ESLint + run: bun run lint:eslint diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 00000000..a77ada93 --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,30 @@ +name: "๐Ÿ‘€ Preview Builder" +on: + pull_request: + workflow_dispatch: + +jobs: + build_and_preview: + env: + NUXT_UI_PRO_LICENSE: ${{ secrets.NUXT_UI_PRO_LICENSE }} + if: ${{ github.event_name == 'workflow_dispatch' || github.event.pull_request.head.repo.full_name == github.repository }} + runs-on: ubuntu-latest + outputs: + output_urls: "${{ steps.preview_deploy.outputs.urls }}" + steps: + - uses: actions/checkout@v4 # v4 + + - uses: oven-sh/setup-bun@v1 + + - name: "Install dependencies" + run: bun install + - name: "Deploy target: staging" + run: bun run docs:build + + - name: "Deploy preview" + uses: matter-labs/action-hosting-deploy@main + with: + repoToken: '${{ secrets.GITHUB_TOKEN }}' + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZKSYNC_DOCS }}" + target: staging + projectId: zksync-docs \ No newline at end of file diff --git a/.github/workflows/deploy-prod.yml b/.github/workflows/deploy-prod.yml new file mode 100644 index 00000000..f8033d0e --- /dev/null +++ b/.github/workflows/deploy-prod.yml @@ -0,0 +1,56 @@ +name: "๐Ÿš€ Deploy Preview" +on: + push: + branches: [main] + +jobs: + build_and_deploy: + env: + NUXT_UI_PRO_LICENSE: ${{ secrets.NUXT_UI_PRO_LICENSE }} + if: ${{ github.event.repository.full_name == github.repository }} + runs-on: ubuntu-latest + environment: prod + steps: + - uses: actions/checkout@v4 # v4 + with: + fetch-depth: 0 + # Whether to configure the token or SSH key with the local git config + # Default: true + persist-credentials: false # <--- checking this in commit context + + - uses: oven-sh/setup-bun@v1 + + - name: "Install dependencies" + run: bun install + - name: "Deploy target: staging" + run: bun run docs:build + # TODO: ask about below + # env: + # RUDDERSTACK_WRITE_KEY: "${{ secrets.RUDDERSTACK_WRITE_KEY }}" + # RUDDERSTACK_DATA_PLANE_URL: "${{ secrets.RUDDERSTACK_DATA_PLANE_URL }}" + + - uses: matter-labs/action-hosting-deploy@main + with: + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZKSYNC_DOCS }}" + target: prod + projectId: zksync-docs + channelId: live + + # TODO: re-enable once we are closer to production deployment + # - name: Purge cf cache + # uses: nathanvaughn/actions-cloudflare-purge@db8c58f61ba4c3ec77229c8fa14ddebb3b59932f # v3.1.0 + # with: + # cf_zone: ${{ secrets.CLOUDFLARE_ZONE }} + # cf_auth: ${{ secrets.CLOUDFLARE_AUTH_KEY }} + # hosts: | + # docs.zksync.io + # era.zksync.io + # v2-docs.zksync.io + + # TODO: Implement reindex task tracking instead of blindly exiting on task submit + # - name: Trigger Algolia reindex + # run: | + # curl -X POST "${{ secrets.ALGOLIA_CRAWLER_BASE_URL }}/crawlers/${{ secrets.ALGOLIA_CRAWLER_ID }}/reindex" \ + # -H "Content-Type: application/json" \ + # --user "${{ secrets.ALGOLIA_CRAWLER_USER_ID }}:${{ secrets.ALGOLIA_CRAWLER_API_KEY }}" \ No newline at end of file diff --git a/.github/workflows/deploy-staging.yml b/.github/workflows/deploy-staging.yml new file mode 100644 index 00000000..c6276d53 --- /dev/null +++ b/.github/workflows/deploy-staging.yml @@ -0,0 +1,30 @@ +name: "๐Ÿ—๏ธ Staging Builder" +on: + push: + branches: [staging] + +jobs: + build_and_deploy: + env: + NUXT_UI_PRO_LICENSE: ${{ secrets.NUXT_UI_PRO_LICENSE }} + if: ${{ github.event.repository.full_name == github.repository }} + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 # v4 + with: + ref: "${{ github.event.inputs.ref }}" + + - uses: oven-sh/setup-bun@v1 + + - name: "Install dependencies" + run: bun install + - name: "Deploy target: staging" + run: bun run docs:build + + - uses: matter-labs/action-hosting-deploy@main + with: + repoToken: "${{ secrets.GITHUB_TOKEN }}" + firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZKSYNC_DOCS }}" + target: staging + projectId: zksync-docs + channelId: live \ No newline at end of file diff --git a/.github/workflows/firebase-hosting-merge.yml b/.github/workflows/firebase-hosting-merge.yml deleted file mode 100644 index 9af63385..00000000 --- a/.github/workflows/firebase-hosting-merge.yml +++ /dev/null @@ -1,20 +0,0 @@ -# This file was auto-generated by the Firebase CLI -# https://github.com/firebase/firebase-tools - -name: Deploy to Firebase Hosting on merge -'on': - push: - branches: - - main -jobs: - build_and_deploy: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: bun run build - - uses: FirebaseExtended/action-hosting-deploy@v0 - with: - repoToken: '${{ secrets.GITHUB_TOKEN }}' - firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZKSYNC_DOCS }}' - channelId: live - projectId: zksync-docs diff --git a/.github/workflows/firebase-hosting-pull-request.yml b/.github/workflows/firebase-hosting-pull-request.yml deleted file mode 100644 index df1d4f35..00000000 --- a/.github/workflows/firebase-hosting-pull-request.yml +++ /dev/null @@ -1,21 +0,0 @@ -# This file was auto-generated by the Firebase CLI -# https://github.com/firebase/firebase-tools - -name: Deploy to Firebase Hosting on PR -'on': pull_request -permissions: - checks: write - contents: read - pull-requests: write -jobs: - build_and_preview: - if: '${{ github.event.pull_request.head.repo.full_name == github.repository }}' - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - run: bun run build - - uses: FirebaseExtended/action-hosting-deploy@v0 - with: - repoToken: '${{ secrets.GITHUB_TOKEN }}' - firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_ZKSYNC_DOCS }}' - projectId: zksync-docs diff --git a/.github/workflows/secrets_scanner.yaml b/.github/workflows/secrets_scanner.yaml index 4be8437d..ff4ff92f 100644 --- a/.github/workflows/secrets_scanner.yaml +++ b/.github/workflows/secrets_scanner.yaml @@ -1,9 +1,9 @@ -name: Leaked Secrets Scan +name: secret ๐Ÿ” on: pull_request: merge_group: jobs: - TruffleHog: + scan: runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/app.vue b/app.vue index 6a1a44f8..b31c0f44 100644 --- a/app.vue +++ b/app.vue @@ -1,5 +1,7 @@ - + diff --git a/pages/index.vue b/pages/index.vue index 414cbb11..a74d277f 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -19,7 +19,6 @@ const particlesLoaded = async (container: unknown) => {
- - - - - Page Not Found - - - - -
-

404

-

Page Not Found

-

The specified file was not found on this website. Please check the URL for mistakes and try again.

-

Why am I seeing this?

-

This page was generated by the Firebase Command-Line Interface. To modify it, edit the 404.html file in your project's configured public directory.

-
- - diff --git a/public/index.html b/public/index.html deleted file mode 100644 index a8785d73..00000000 --- a/public/index.html +++ /dev/null @@ -1,89 +0,0 @@ - - - - - - Welcome to Firebase Hosting - - - - - - - - - - - - - - - - - - - -
-

Welcome

-

Firebase Hosting Setup Complete

-

You're seeing this because you've successfully setup Firebase Hosting. Now it's time to go build something extraordinary!

- Open Hosting Documentation -
-

Firebase SDK Loading…

- - - -