Review existing components #327
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: Deploy | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- run: corepack enable | |
- name: Setup node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: package.json | |
cache: pnpm | |
cache-dependency-path: pnpm-lock.yaml | |
- name: Install dependencies | |
run: pnpm install | |
- name: Cache for Next | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- | |
${{ runner.os }}-nextjs- | |
- name: Validate build | |
run: pnpm run build | |
test: | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- run: corepack enable | |
- name: Setup node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: package.json | |
cache: pnpm | |
cache-dependency-path: pnpm-lock.yaml | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run tests | |
run: pnpm run test --coverage | |
- name: Store coverage results | |
uses: actions/upload-artifact@v4 | |
with: | |
name: coverage | |
path: coverage/ | |
retention-days: 1 | |
deploy: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
outputs: | |
deployUrl: ${{ steps.deploy.outputs.deployUrl }} | |
deployId: ${{ steps.deploy.outputs.deployId }} | |
env: | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- run: corepack enable | |
- name: Setup node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: package.json | |
cache: pnpm | |
cache-dependency-path: pnpm-lock.yaml | |
- name: Cache for Next | |
uses: actions/cache@v4 | |
with: | |
path: ${{ github.workspace }}/.next/cache | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/pnpm-lock.yaml') }}- | |
${{ runner.os }}-nextjs- | |
- name: Install Vercel CLI | |
run: npm install --global vercel | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Build Project Artifacts | |
run: vercel build --prod --token=${{ secrets.VERCEL_TOKEN }} | |
- id: deploy | |
name: Deploy Project Artifacts to Vercel | |
run: | | |
DEPLOY_URL=$(vercel deploy --prebuilt --prod --skip-domain --token=${{ secrets.VERCEL_TOKEN }}) | |
echo "deployUrl=$DEPLOY_URL" >> "$GITHUB_OUTPUT" | |
DEPLOY_ID=$(echo $DEPLOY_URL | cut -d'-' -f2) | |
echo "deployId=$DEPLOY_ID" >> "$GITHUB_OUTPUT" | |
sonar: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
needs: | |
- test | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis | |
- run: corepack enable | |
- name: Setup node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: package.json | |
cache: pnpm | |
cache-dependency-path: pnpm-lock.yaml | |
- name: Install dependencies | |
run: pnpm install | |
- uses: actions/download-artifact@v4 | |
with: | |
name: coverage | |
path: coverage | |
- name: Upload coverage reports to Codecov | |
uses: codecov/codecov-action@v4 | |
env: | |
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} | |
- name: SonarCloud Scan | |
uses: SonarSource/sonarcloud-github-action@master | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | |
promote: | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
timeout-minutes: 10 | |
runs-on: ubuntu-latest | |
container: | |
image: mcr.microsoft.com/playwright:v1.41.2 | |
needs: | |
- build | |
- test | |
- deploy | |
env: | |
HOME: /root | |
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- run: corepack enable | |
- name: Setup node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version-file: package.json | |
cache: pnpm | |
cache-dependency-path: pnpm-lock.yaml | |
- name: Install dependencies | |
run: pnpm install | |
- name: Run Playwright tests | |
run: pnpm run test:e2e:service | |
env: | |
BASE_URL: ${{ needs.deploy.outputs.deployUrl }} | |
PLAYWRIGHT_SERVICE_ACCESS_TOKEN: ${{ secrets.PLAYWRIGHT_SERVICE_ACCESS_TOKEN }} | |
PLAYWRIGHT_SERVICE_URL: ${{ secrets.PLAYWRIGHT_SERVICE_URL }} | |
PLAYWRIGHT_USER_EMAIL: ${{ secrets.PLAYWRIGHT_USER_EMAIL }} | |
PLAYWRIGHT_USER_PASSWORD: ${{ secrets.PLAYWRIGHT_USER_PASSWORD }} | |
- name: Install Vercel CLI | |
run: npm install --global vercel | |
- name: Pull Vercel Environment Information | |
run: vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }} | |
- name: Flag the deployment as promoted | |
run: >- | |
curl -X 'PATCH' 'https://api.vercel.com/v1/edge-config/${{secrets.VERCEL_EDGE_CONFIG_ID}}/items' | |
-H 'Authorization: Bearer ${{secrets.VERCEL_TOKEN}}' | |
-H 'Content-Type: application/json' | |
-d '{ "items": [ { "operation": "create", "key": "${{needs.deploy.outputs.deployId}}", "value": "promoted" } ] }' | |
- name: Promote the Deployment | |
run: vercel promote ${{needs.deploy.outputs.deployUrl}} --scope=${{ secrets.VERCEL_ORG_ID }} --token=${{ secrets.VERCEL_TOKEN }} | |
- uses: actions/upload-artifact@v4 | |
if: always() | |
with: | |
name: playwright-report | |
path: playwright-report/ | |
retention-days: 10 |