Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Add cloudflare deployment, develop PRs and merge to main for prod. PR deploys pr-# #29

Merged
merged 5 commits into from
Aug 4, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
91 changes: 88 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,113 @@
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
node-version: '18.17.0'
cache: 'yarn'

- 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: '18.17.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/[email protected]
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
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 != '' }}
uses: cloudflare/[email protected]
with:
apiToken: ${{ secrets.CF_API_TOKEN }}
accountId: ${{ secrets.CF_ACCOUNT_ID }}
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

- 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 }})
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v18.17.0
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -84,5 +85,8 @@
"prettier --list-different",
"stylelint"
]
},
"dependencies": {
"cross-env": "^7.0.3"
}
}
15 changes: 14 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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:
Expand Down Expand Up @@ -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
Expand Down