From b8b4180065e8ac972185f7ce3e7c364d552cd5f6 Mon Sep 17 00:00:00 2001 From: Andreas Richter <708186+richtera@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:34:49 -0400 Subject: [PATCH 1/5] fix: Add cloudflare deployment. --- .github/workflows/ci.yml | 88 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 86 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index adff7f48..2c4ae137 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,28 +1,112 @@ -name: Tests +name: Lint, Test, Build + on: pull_request: branches: - - '*' + - 'main' + - 'develop' + push: + branches: + - 'main' + - 'develop' + +env: + CF_PROJECT_NAME: wallet-universalprofile-cloud + CF_BASE_URL: wallet-universalprofile-cloud + jobs: test: timeout-minutes: 60 runs-on: macos-latest steps: - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 with: node-version: 16 + - name: ⚙️ Install dependencies run: yarn install + - name: 🎨 Lint run: yarn lint + - name: 🛠 Install Playwright Browsers run: npx playwright install --with-deps chromium + - name: 🎯 Run Playwright tests run: npx playwright test + - uses: actions/upload-artifact@v3 if: always() with: name: playwright-report path: playwright-report/ retention-days: 30 + + build-lint-test: + runs-on: ubuntu-latest + needs: test + + steps: + - name: Extract branch name + shell: bash + run: | + PR_NUMBER="${{ github.event.number }}" + if [ -n "$PR_NUMBER" ] + then + echo "branch_name=pr-${PR_NUMBER}" >> $GITHUB_OUTPUT + echo "url=https://pr-${PR_NUMBER}.${{ env.CF_BASE_URL }}.pages.dev" >> $GITHUB_OUTPUT + else + if [ "${{ github.ref }}" = "refs/heads/develop" ] + then + echo "branch_name=develop" >> $GITHUB_OUTPUT + echo "url=https://develop.${{ env.CF_BASE_URL }}.pages.dev" >> $GITHUB_OUTPUT + else + echo "branch_name=" >> $GITHUB_OUTPUT + fi + fi + + id: extract_branch + + - name: Checkout + uses: actions/checkout@v3 + + - uses: actions/setup-node@v3 + with: + node-version: '16.20.0' + cache: 'yarn' + + - name: Install + run: yarn install + + - name: Build + run: yarn run pages:build + + - name: 'Deploy release' + if: ${{ steps.extract_branch.outputs.branch_name == '' }} + uses: cloudflare/wrangler-action@2.0.0 + with: + apiToken: ${{ secrets.CF_API_TOKEN }} + accountId: ${{ secrets.CF_ACCOUNT_ID }} + command: pages deploy --project-name "${{ env.CF_PROJECT_NAME }}" .vercel/output/static + + - name: Deploy ${{ steps.extract_branch.outputs.branch_name }} (PR) + if: ${{ steps.extract_branch.outputs.branch_name != '' }} + uses: cloudflare/wrangler-action@2.0.0 + with: + apiToken: ${{ secrets.CF_API_TOKEN }} + accountId: ${{ secrets.CF_ACCOUNT_ID }} + command: pages deploy --project-name "${{ env.CF_PROJECT_NAME }}" .vercel/output/static --branch "${{ steps.extract_branch.outputs.branch_name }}" | tee output.log + postCommands: | + sed < output.log -n 's#.*Take a peek over at \(.*\)$#specific_url=\1#p' >> $GITHUB_OUTPUT + id: deploy + + - name: Create commit comment + uses: mshick/add-pr-comment@v2 + if: ${{ steps.extract_branch.outputs.branch_name != '' }} + with: + message: | + ### Deployed with **Cloudflare Pages** :cloud: :rocket: :ok: + - **URL**: [${{ steps.extract_branch.outputs.url }}](${{ steps.extract_branch.outputs.url }}) + - **Specific**: [${{ steps.deploy.outputs.specific_url }}](${{ steps.deploy.outputs.specific_url }}) From 1fcffd172321320e83ad6621c50d785f68102fc9 Mon Sep 17 00:00:00 2001 From: Andreas Richter <708186+richtera@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:40:23 -0400 Subject: [PATCH 2/5] fix: Repair lint error. --- .github/workflows/ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2c4ae137..92e2e143 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -30,13 +30,13 @@ jobs: - name: 🎨 Lint run: yarn lint - + - name: 🛠 Install Playwright Browsers run: npx playwright install --with-deps chromium - + - name: 🎯 Run Playwright tests run: npx playwright test - + - uses: actions/upload-artifact@v3 if: always() with: From 612410d967532b16fe27fd5db622b7a5a6ddcdc0 Mon Sep 17 00:00:00 2001 From: Andreas Richter <708186+richtera@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:43:55 -0400 Subject: [PATCH 3/5] fix: Caching should be the same. --- .github/workflows/ci.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 92e2e143..1f31bedd 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,7 +23,8 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: 16 + node-version: '18.17.0' + cache: 'yarn' - name: ⚙️ Install dependencies run: yarn install @@ -74,7 +75,7 @@ jobs: - uses: actions/setup-node@v3 with: - node-version: '16.20.0' + node-version: '18.17.0' cache: 'yarn' - name: Install From fdf5711ae1963a07c516cefa0e2ae28c3f4cda6b Mon Sep 17 00:00:00 2001 From: Andreas Richter <708186+richtera@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:47:02 -0400 Subject: [PATCH 4/5] fix: Add .nvmrc --- .nvmrc | 1 + 1 file changed, 1 insertion(+) create mode 100644 .nvmrc diff --git a/.nvmrc b/.nvmrc new file mode 100644 index 00000000..cbd89321 --- /dev/null +++ b/.nvmrc @@ -0,0 +1 @@ +v18.17.0 \ No newline at end of file From dd1a66413799513756b8dc66cd6fb305f84c7902 Mon Sep 17 00:00:00 2001 From: Andreas Richter <708186+richtera@users.noreply.github.com> Date: Thu, 3 Aug 2023 13:59:14 -0400 Subject: [PATCH 5/5] fix: Add pages build. --- .github/workflows/ci.yml | 4 ++-- package.json | 6 +++++- yarn.lock | 15 ++++++++++++++- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1f31bedd..d90f6861 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -90,7 +90,7 @@ jobs: with: apiToken: ${{ secrets.CF_API_TOKEN }} accountId: ${{ secrets.CF_ACCOUNT_ID }} - command: pages deploy --project-name "${{ env.CF_PROJECT_NAME }}" .vercel/output/static + command: pages deploy --project-name "${{ env.CF_PROJECT_NAME }}" dist - name: Deploy ${{ steps.extract_branch.outputs.branch_name }} (PR) if: ${{ steps.extract_branch.outputs.branch_name != '' }} @@ -98,7 +98,7 @@ jobs: with: apiToken: ${{ secrets.CF_API_TOKEN }} accountId: ${{ secrets.CF_ACCOUNT_ID }} - command: pages deploy --project-name "${{ env.CF_PROJECT_NAME }}" .vercel/output/static --branch "${{ steps.extract_branch.outputs.branch_name }}" | tee output.log + command: pages deploy --project-name "${{ env.CF_PROJECT_NAME }}" dist --branch "${{ steps.extract_branch.outputs.branch_name }}" | tee output.log postCommands: | sed < output.log -n 's#.*Take a peek over at \(.*\)$#specific_url=\1#p' >> $GITHUB_OUTPUT id: deploy diff --git a/package.json b/package.json index 18ccbf38..606f2959 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,8 @@ "yata-fetch": "dotenv -- yata-fetch --config .yata.json", "test": "npx playwright test", "test:ui": "npx playwright test --ui", - "test:debug": "npx playwright test --debug" + "test:debug": "npx playwright test --debug", + "pages:build": "cross-env NODE_ENV=production NITRO_PRESET=cloudflare_pages nuxt build --standalone" }, "devDependencies": { "@esbuild-plugins/node-globals-polyfill": "0.2.3", @@ -84,5 +85,8 @@ "prettier --list-different", "stylelint" ] + }, + "dependencies": { + "cross-env": "^7.0.3" } } diff --git a/yarn.lock b/yarn.lock index a674d517..098a14d4 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3896,6 +3896,18 @@ __metadata: languageName: node linkType: hard +"cross-env@npm:^7.0.3": + version: 7.0.3 + resolution: "cross-env@npm:7.0.3" + dependencies: + cross-spawn: ^7.0.1 + bin: + cross-env: src/bin/cross-env.js + cross-env-shell: src/bin/cross-env-shell.js + checksum: 26f2f3ea2ab32617f57effb70d329c2070d2f5630adc800985d8b30b56e8bf7f5f439dd3a0358b79cee6f930afc23cf8e23515f17ccfb30092c6b62c6b630a79 + languageName: node + linkType: hard + "cross-fetch@npm:^3.1.5": version: 3.1.8 resolution: "cross-fetch@npm:3.1.8" @@ -3918,7 +3930,7 @@ __metadata: languageName: node linkType: hard -"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": +"cross-spawn@npm:^7.0.0, cross-spawn@npm:^7.0.1, cross-spawn@npm:^7.0.2, cross-spawn@npm:^7.0.3": version: 7.0.3 resolution: "cross-spawn@npm:7.0.3" dependencies: @@ -12276,6 +12288,7 @@ __metadata: "@typescript-eslint/eslint-plugin": 6.2.1 "@typescript-eslint/parser": 6.2.1 buffer: 6.0.3 + cross-env: ^7.0.3 dotenv-cli: 7.2.1 eslint: 8.46.0 eslint-config-prettier: 8.9.0