feat: enhance CI/CD workflow with GitHub deployment steps and error h… #19
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 and Deploy | |
| on: | |
| push: | |
| branches: | |
| - main | |
| permissions: | |
| contents: read | |
| deployments: write | |
| id-token: write | |
| concurrency: | |
| group: ci-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| ci-deploy: | |
| name: Test and Deploy | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| cache: npm | |
| cache-dependency-path: package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build project | |
| run: npm run build | |
| - name: Deploy to Vercel | |
| id: vercel_deploy | |
| uses: amondnet/vercel-action@v25 | |
| continue-on-error: true | |
| with: | |
| vercel-token: ${{ secrets.VERCEL_TOKEN }} | |
| vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} | |
| vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} | |
| working-directory: . | |
| vercel-args: '--prod' | |
| - name: Create GitHub deployment | |
| if: always() | |
| id: deployment | |
| uses: bobheadxi/deployments@v1 | |
| with: | |
| step: start | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| env: production | |
| ref: ${{ github.sha }} | |
| - name: Update deployment status | |
| if: always() | |
| uses: bobheadxi/deployments@v1 | |
| with: | |
| step: finish | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| status: ${{ steps.vercel_deploy.outcome == 'success' && 'success' || 'failure' }} | |
| env: ${{ steps.deployment.outputs.env }} | |
| deployment_id: ${{ steps.deployment.outputs.deployment_id }} | |
| env_url: https://devcontext.xyz | |
| - name: Fail job if deployment failed | |
| if: ${{ steps.vercel_deploy.outcome != 'success' }} | |
| run: exit 1 |