Created
September 13, 2025 09:08
-
-
Save alexcastrodev/2a43ac7f1329b22157b0f2bcdf91daa9 to your computer and use it in GitHub Desktop.
Multiple contributors on hobby plan vercel
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: App Deployment | |
| env: | |
| VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} | |
| VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID_WEBSITE }} | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - staging | |
| - '**' | |
| concurrency: | |
| group: app-deployment-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| Deploy-Website: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| run_install: false | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| cache: 'pnpm' | |
| - name: Install workspace deps | |
| run: pnpm install --frozen-lockfile | |
| - name: Install Vercel CLI | |
| run: pnpm add -g vercel@latest | |
| # Determine environment based on branch | |
| - name: Set deployment environment | |
| id: env | |
| run: | | |
| if [ "${{ github.ref_name }}" = "main" ]; then | |
| echo "environment=production" >> $GITHUB_OUTPUT | |
| echo "vercel_env=production" >> $GITHUB_OUTPUT | |
| echo "vercel_flags=--prod" >> $GITHUB_OUTPUT | |
| echo "build_flags=--prod" >> $GITHUB_OUTPUT | |
| else | |
| echo "environment=preview" >> $GITHUB_OUTPUT | |
| echo "vercel_env=preview" >> $GITHUB_OUTPUT | |
| echo "vercel_flags=" >> $GITHUB_OUTPUT | |
| echo "build_flags=" >> $GITHUB_OUTPUT | |
| fi | |
| - name: Save branch name | |
| run: echo "BRANCH_NAME=${GITHUB_REF#refs/heads/}" >> $GITHUB_ENV | |
| - name: Remove git folder | |
| run: rm -rf .git | |
| - name: Setup git | |
| run: | | |
| git config --global user.email "[email protected]" | |
| git config --global user.name "developers" | |
| - name: Pull Vercel Environment | |
| run: vercel pull --yes --environment=${{ steps.env.outputs.vercel_env }} --token=${{ secrets.VERCEL_TOKEN }} | |
| - name: Build project artifacts | |
| run: vercel build ${{ steps.env.outputs.build_flags }} --token=${{ secrets.VERCEL_TOKEN }} | |
| - name: Deploy to ${{ steps.env.outputs.environment }} | |
| id: deploy | |
| run: | | |
| DEPLOYMENT_OUTPUT=$(vercel --prebuilt deploy --archive=tgz ${{ steps.env.outputs.vercel_flags }} --token=${{ secrets.VERCEL_TOKEN }}) | |
| echo "deployment_output=$DEPLOYMENT_OUTPUT" >> $GITHUB_OUTPUT | |
| DEPLOYMENT_URL=$(echo "$DEPLOYMENT_OUTPUT" | grep -o 'https://[^[:space:]]*\.vercel\.app') | |
| echo "deployment_url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT | |
| echo "Deployment URL: $DEPLOYMENT_URL" | |
| echo "$DEPLOYMENT_OUTPUT" | |
| - name: Alias staging deployment | |
| if: github.ref_name == 'staging' | |
| run: vercel --scope=nameofteam alias set ${{ steps.deploy.outputs.deployment_url }} staging.site.com --token=${{ secrets.VERCEL_TOKEN }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment