feat: Add Elfsight platform flow #1580
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: Lint, Test, Build | |
on: | |
pull_request: | |
branches: | |
- '**' | |
push: | |
branches: | |
- 'main' | |
- 'develop' | |
env: | |
CF_PROJECT_NAME: wallet-universalprofile-cloud | |
CF_BASE_URL: wallet-universalprofile-cloud | |
ALGOLIA_API_KEY: '${{ secrets.ALGOLIA_API_KEY }}' | |
ALGOLIA_APPLICATION_ID: '${{ secrets.ALGOLIA_APPLICATION_ID }}' | |
NUXT_PUBLIC_SENTRY_DSN: '${{ secrets.SENTRY_DSN }}' | |
NUXT_PUBLIC_SENTRY_ENABLED: '${{ secrets.SENTRY_ENABLED }}' | |
NUXT_PUBLIC_SENTRY_ENVIRONMENT: '${{ secrets.SENTRY_ENVIRONMENT }}' | |
NUXT_PUBLIC_TRANSAK_API_KEY: '${{ secrets.TRANSAK_API_KEY }}' | |
NUXT_PUBLIC_RAMP_API_KEY: '${{ secrets.RAMP_API_KEY }}' | |
NUXT_PUBLIC_API_SHARED_SECRET: '${{ secrets.API_SHARED_SECRET }}' | |
jobs: | |
test: | |
runs-on: macos-latest | |
timeout-minutes: 20 | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '20.0.0' | |
cache: 'yarn' | |
- name: ⚙️ Install dependencies | |
run: yarn install --inline-builds | |
- name: 🎨 Lint | |
run: yarn prepare && yarn lint | |
- name: 🎯 Run Unit tests | |
run: yarn test:unit:ci | |
deploy: | |
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: '20.0.0' | |
cache: 'yarn' | |
- name: Install | |
run: yarn install | |
- name: Build | |
run: | | |
yarn prepare | |
NODE_ENV=production 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 }}) |