Deploy and Preview Your Pull Request using Vercel
How to use
- ถ้ามีการเชื่อมต่อ Vercel กับ Github ให้ปิดการเชื่อมต่อก่อน เพราะว่าเราต้องการให้ github actions build and deploy แทนที่ Vercel (ซึ่งโดยปกติ Vercel จะ build และ deploy ให้อัตโนมัติ) Read More
- You should link Github Project with Vercel locally (For Vercel CLI 17)
- Define Github Actions
# https://github.com/marketplace/actions/vercel-actionname: Preview deployon: pull_request: branches: - main pull_request_target:jobs: deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - uses: amondnet/vercel-action@v20 id: vercel-action with: vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required github-token: ${{ secrets.PUBLIC_REPO_ACCESS_TOKEN }} #Optional vercel-org-id: ${{ secrets.VERCEL_ORG_ID}} #Required vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID}} #Required - name: preview-url run: | echo ${{ steps.vercel-action.outputs.preview-url }}
- กำหนดค่าที่ต้องใช้ ทั้ง GitHub Secrets และ Vercel
Secret key | Secret value |
---|---|
VERCEL_TOKEN | ต้องสร้างจาก https://vercel.com/account/tokens |
PUBLIC_REPO_ACCESS_TOKEN | ต้องกำหนด repo access โดยกำหนด Token ของ github read more |
VERCEL_ORG_ID | ID ของ team ที่เราใช้ แต่ถ้าใช้ Personal ให้เอาจาก account setting ใน Your ID |
VERCEL_PROJECT_ID | เอามาจาก Project ID ใน Project Setting |
สำหรับการตั้งค่าอื่นๆ เพิ่มเติมที่ Vercel Action - GitHub Action