Giter Site home page Giter Site logo

vitorcamachoo / vercel-action Goto Github PK

View Code? Open in Web Editor NEW

This project forked from amondnet/vercel-action

0.0 0.0 1.0 58.88 MB

This action make a deployment with github actions instead of Vercel builder.

Home Page: https://vercel.com/docs/cli

License: MIT License

JavaScript 61.77% TypeScript 31.27% HTML 6.61% CSS 0.36%

vercel-action's Introduction

Vercel Action

deploy website preview test now-deployment action example - static example - basic auth example - angular

stars forks HitCount

Maintainability Rating Technical Debt Bugs Code Smells Reliability Rating Security Rating

This action was formerly Zeit Now Deployment. Migration Guide stars forks

Introduction to Vercel

​Vercel is a cloud platform for static sites and Serverless Functions that fits perfectly with your workflow. It enables developers to host Jamstack websites and web services that deploy instantly, scale automatically, and requires no supervision, all with no configuration.

This action make a Vercel deployment with github actions.

Result

preview

pull request example

commit

Inputs

Name Required Default Description
vercel-token
Vercel token. see https://vercel.com/account/tokens
github-comment
true Its type can be either string or boolean. When string, it leaves PR a comment with the string. When boolean, it leaves PR a default comment(true) or does not leave a comment at all(false).
github-token
if you want to comment on pull request or commit. ${{ secrets.GITHUB_TOKEN }} (GitHub token docs)
vercel-project-id
❗Vercel CLI 17+,The name property in vercel.json is deprecated (https://zeit.ink/5F)
vercel-org-id
❗Vercel CLI 17+,The name property in vercel.json is deprecated (https://zeit.ink/5F)
vercel-args
This is optional args for vercel cli. Example: --prod
working-directory
the working directory
scope
If you are working in a team scope, you should set this value to your team ID.
alias-domains
You can assign a domain to this deployment. Please note that this domain must have been configured in the project. You can use pull request number via {{PR_NUMBER}} and branch via {{BRANCH}}.
vercel-project-name
The name of the project; if absent we'll use the vercel inspect command to determine. #27 & #28

Outputs

preview-url

The url of deployment preview.

preview-name

The name of deployment name.

How To Use

Disable Vercel for GitHub

The Vercel for GitHub integration automatically deploys your GitHub projects with Vercel, providing Preview Deployment URLs, and automatic Custom Domain updates. link

We would like to to use github actions for build and deploy instead of Vercel.

Set github.enabled: false in vercel.json, see example vercel.json file below:

{
  "version": 2,
  "public": false,
  "github": {
    "enabled": false
  },
  "builds": [
    { "src": "./public/**", "use": "@now/static" }
  ],
  "routes": [
    { "src": "/(.*)", "dest": "public/$1" }
  ]
}

When set to false, Vercel for GitHub will not deploy the given project regardless of the GitHub app being installed.

Project Linking

You should link a project via Vercel CLI in locally.

When running vercel in a directory for the first time, Vercel CLI needs to know which scope and Project you want to deploy your directory to. You can choose to either link an existing project or to create a new one.

NOTE: Project linking requires at least version 17 of Vercel CLI. If you have an earlier version, please update to the latest version.

vercel
? Set up and deploy “~/web/my-lovely-project”? [Y/n] y
? Which scope do you want to deploy to? My Awesome Team
? Link to existing project? [y/N] y
? What’s the name of your existing project? my-lovely-project
🔗 Linked to awesome-team/my-lovely-project (created .vercel and added it to .gitignore)

Once set up, a new .vercel directory will be added to your directory. The .vercel directory contains both the organization(vercel-org-id) and project(vercel-project-id) id of your project.

{"orgId":"example_org_id","projectId":"example_project_id"}

You can save both values in the secrets setting in your repository. Read the Official documentation if you want further info on how secrets work on Github.

Github Actions

  • This is a complete .github/workflows/deploy.yml example.

Set the vercel-project-id and vercel-org-id you found above.

name: deploy website
on: [pull_request]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: amondnet/vercel-action@v20
        with:
          vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
          github-token: ${{ secrets.GITHUB_TOKEN }} #Optional 
          vercel-args: '--prod' #Optional
          vercel-org-id: ${{ secrets.ORG_ID}}  #Required
          vercel-project-id: ${{ secrets.PROJECT_ID}} #Required 
          working-directory: ./sub-directory

Angular Example

See .github/workflows/example-angular.yml ,

Basic Auth Example

How to add Basic Authentication to a Vercel deployment

See .github/workflows/example-express-basic-auth.yml

source code

| @now/node-server is deprecated and stopped working. Use @vercel/node instead. #61

Alias Domains

You can assign a domain to this deployment. Please note that this domain must have been configured in the project.

If you want to assign domain to branch or pr, you should add Wildcard Domain.

You can use pull request number via {{PR_NUMBER}} and branch via {{BRANCH}}

Example

Wildcard Domains : *.angular.vercel-action.amond.dev

Per Pull Request

https://pr-{{PR_NUMBER}}.angular.vercel-action.amond.dev

Per Branch

https://{{BRANCH}}.angular.vercel-action.amond.dev

See .github/workflows/example-angular.yml

name: deploy website
on: [pull_request]
jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: amondnet/vercel-action@v19
        with:
          vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required
          github-token: ${{ secrets.GITHUB_TOKEN }} #Optional 
          vercel-args: '--prod' #Optional
          vercel-org-id: ${{ secrets.ORG_ID}}  #Required
          vercel-project-id: ${{ secrets.PROJECT_ID}} #Required 
          working-directory: ./sub-directory #Your Working Directory, Optional
          alias-domains: | #Optional
            staging.angular.vercel-action.amond.dev
            pr-{{PR_NUMBER}}.angular.vercel-action.amond.dev

Migration from v2

  1. Change action name in workflows from now-deployment to vercel-action
     - name: Vercel Action
       uses: amondnet/vercel-action@v19
  2. Change input values.
    • zeit-token -> vercel-token
    • now-org-id -> vercel-org-id
    • now-project-id -> vercel-project-id

vercel-action's People

Contributors

amondnet avatar iam4x avatar dependabot[bot] avatar aulneau avatar vitorcamachoo avatar foxundermoon avatar amalv avatar kimjson avatar sunderipranata avatar olivercoad avatar ocavue avatar caoer avatar nionis avatar shunkakinoki avatar rodrigorm avatar richardtapendium avatar claranceliberi avatar hakonkrogh avatar evanlovely avatar zdhz avatar andyrichardson avatar

Forkers

yacooba

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.