Feature/form #1
This file contains hidden or 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: CI/CD Workflow --> Deploy and Run E2E Tests | |
| on: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| jobs: | |
| deploy: | |
| name: Deploy to Vercel-->1 | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Code | |
| uses: actions/checkout@v4 | |
| - name: Install Vercel CLI | |
| run: npm install --global vercel@latest | |
| - name: Pull Vercel Environment Information | |
| run: | | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | |
| else | |
| vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | |
| fi | |
| - name: Build Project Artifacts | |
| run: | | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| vercel build --prod --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | |
| else | |
| vercel build --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | |
| fi | |
| - name: Deploy to Vercel-->2 | |
| id: deploy | |
| run: | | |
| if [[ "${{ github.ref }}" == "refs/heads/main" ]]; then | |
| DEPLOY_URL=$(vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | tail -1) | |
| else | |
| DEPLOY_URL=$(vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | tail -1) | |
| fi | |
| echo "DEPLOYMENT_URL=${DEPLOY_URL}" >> $GITHUB_ENV | |
| echo "Deployed to: $DEPLOY_URL" | |
| env: | |
| VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN_MY_PROJECT }} | |
| e2e-tests: | |
| name: Run E2E Tests | |
| runs-on: ubuntu-latest | |
| needs: deploy | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Install Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: latest | |
| run_install: false | |
| - name: Get pnpm store directory | |
| shell: bash | |
| run: | | |
| echo "STORE_PATH=$(pnpm store path --silent)" >> $GITHUB_ENV | |
| - name: Setup pnpm cache | |
| uses: actions/cache@v4 | |
| with: | |
| path: ${{ env.STORE_PATH }} | |
| key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-pnpm-store- | |
| - name: Install packages | |
| run: pnpm install --frozen-lockfile | |
| - name: Install Playwright dependencies | |
| run: pnpm exec playwright install-deps | |
| - name: Install Playwright | |
| run: pnpm exec playwright install | |
| - name: Run Playwright Tests | |
| run: pnpm test:e2e | |
| env: | |
| BASE_URL: ${{ env.DEPLOYMENT_URL }} |