Are you tired of seeing All checks have failed. Vercel - Git author [username] must have access to the project on Vercel to create deployments.
?
You do not have to see that anymore. I created this GitHub Actions workflow guide that allows you to collaborate with your team on the Vercel Hobby plan. It automatically deploys your changes for any collaborator on the repository!
This guide is only for educational purposes. I just want to people to learn how to setup GitHub Actions, save time, and save money :)
Vercel has disabled collaboration on the Hobby plan. This means that only the repository owner is able to commit and deploy the changes to a Vercel Hobby private project. Now users have to be invited to a team and pay U$20/month per user to collaborate.
I love Vercel and their services (in fact, I use Vercel for everything and have bought many domains using Vercel), but there is no way that I'm paying U$20/month for each user on a project. I find that really crazy. If I have 5 people working on a repository, it'll be U$100/month for one team. Say I have many teams: that might cost thousands of dollars a month.
This is just the better (and free) alternative if you're just trying to collaborate on simple projects.
- Create a
.github
folder in the root folder of your application - Create a
workflows
folder inside the.github
folder - Inside the
github/workflows
folder, create aproduction.yaml
file - Copy the following code snippet and paste it to the
production.yaml
file, then commit your changes
name: Vercel Production Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:
branches:
- main
jobs:
Deploy-Production:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Vercel CLI
run: npm install --global vercel@latest
- 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 }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --prod --token=${{ secrets.VERCEL_TOKEN }}
- View the
Actions
tab on the GitHub repository to see the workflow run (it will fail initially but don't worry it's expected!) - The workflow run has failed because it's missing the environment variables
VERCEL_ORG_ID
,VERCEL_PROJECT_ID
, andVERCEL TOKEN
. We need to add the environment variables now. VERCEL_ORG_ID
is the Team ID- This can be found on https://vercel.com/[your-team-name] on the
Settings
tab
- This can be found on https://vercel.com/[your-team-name] on the
VERCEL_PROJECT_ID
is the Project ID- This can be found on https://vercel.com/[your-team-name]/[your-project-name] on the
Settings
tab
- This can be found on https://vercel.com/[your-team-name]/[your-project-name] on the
VERCEL_TOKEN
is a token that allow other apps to control your whole account. Be careful!- Go to
Account Settigns
>Tokens
- Choose a specific token name like [project-name-github-actions-workflow] and select the scope as the Team that is working on the project
- Choose an expiration date and click
Create
- Copy the token and store it somewhere temporarily (don't share it with anyone!)
- Go to
- Now that you have all the environment variables, go to your GitHub repository and click
Settings
- Go to
Secrets and variables
>Actions
- Add each repository secret
New Repository Secret
- Write the environment variable as the Name (e.g. VERCEL_ORG_ID) and paste the secret on Secret
- Push any changes to the repository to run the workflow, and it should pass now! Now anyone who has access to your repository is able to commit and deploy to Vercel on the Hobby plan!
- Create a
.github/workflows
folder in the root folder of your application - Create a
worfklows
folder inside the.github
folder - Inside the
.github/workflows
folder, create apreview.yaml
file - Copy the following code snippet and paste it to the
preview.yaml
file, then commit your changes- Please note that it adds
main
tobranches-ignore:
which means all branches can trigger the workflow - Configure to your needs and add your
[branch-name]
to abranch:
if you only want the workflow to run on a specific branch
- Please note that it adds
name: Vercel Preview Deployment
env:
VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }}
VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }}
on:
push:
branches-ignore:
- main
jobs:
Deploy-Preview:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Install Vercel CLI
run: npm install --global vercel@latest
- name: Pull Vercel Environment Information
run: vercel pull --yes --environment=preview --token=${{ secrets.VERCEL_TOKEN }}
- name: Build Project Artifacts
run: vercel build --token=${{ secrets.VERCEL_TOKEN }}
- name: Deploy Project Artifacts to Vercel
run: vercel deploy --prebuilt --token=${{ secrets.VERCEL_TOKEN }}
- Follow the same steps as above for production environments
-
- IDE: This can be done manually by creating a
.github
folder and aworkflows
folder inside and pushing your changes - Github.com: Go to the repository on github.com and click
Actions
thenset up a workflow yourself
which will automatically create a.github/workflows
folder.
- IDE: This can be done manually by creating a
-
- This can be found on https://vercel.com/[your-team-name] on the
Settings
tab - It is also known as the Team ID (yes, I know it's confusing)
- It should look something like
team_ABCDEFG123456
- This can be found on https://vercel.com/[your-team-name] on the
-
- This can be found on https://vercel.com/[your-team-name]/[your-project-name] on the
Settings
tab - It should look something like
prj_ABCDEFG123456
- This can be found on https://vercel.com/[your-team-name]/[your-project-name] on the
-
- Click your profile picture or account
- Click
Account Settings
- Click
Tokens
- Choose a specific token name like [project-name-github-actions-workflow] and select the scope as the Team that is working on the project.
- Choose an expiration date and click
Create
. - Copy the token and store it somewhere temporarily (don't share it with anyone!)
- You can always manage and delete your tokens at any time!
-
- Open the GitHub repository and on https://github.com
- Click
Settings
>Secrets and variables
>Actions
- Click
New Repository Secret
- Add each environment variable like
VERCEL_ORG_ID
as the name andteam_ABCDEFG123456
as the secret.
- Add each environment variable like
-
- Yes, this is allowed. In fact, it is even mentioned in their own official guide (link below).
Collaborators are welcome! Feel free to help me if I'm missing anything or if you have configuration suggestions for a specific workflow!
- Vercel Hobby Plan Collaboration
- Vercel Free Plan Collaboration
- Vercel Hobby Plan Deployment
- Vercel Hobby Plan CI/CD
- Vercel Hobby Plan Automatic Deployment GitHub Actions
- Git author must have access to the project on Vercel to create deployments.