• Stars
    star
    143
  • Rank 257,007 (Top 6 %)
  • Language
    TypeScript
  • Created over 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐Ÿ”‚ Preview website in surge.sh for every pull request.

Surge PR Preview

CI status

A GitHub action that preview website in surge.sh for your pull requests.

image

image

Pros

Compare to Netlify/Vercel?

  • It is free.
  • It supports multiple preview jobs.

Usage

Add a workflow (.github/workflows/preview.yml):

name: ๐Ÿ”‚ Surge PR Preview

on: [pull_request]

jobs:
  preview:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write # allow surge-preview to create/update PR comments
    steps:
      - uses: actions/checkout@v2
      - uses: afc163/surge-preview@v1
        id: preview_step
        with:
          surge_token: ${{ secrets.SURGE_TOKEN }}
          dist: public
          build: |
            npm install
            npm run build
      - name: Get the preview_url
        run: echo "url => ${{ steps.preview_step.outputs.preview_url }}"

The preview website url will be https://{{repository.owner}}-{{repository.name}}-{{job.name}}-pr-{{pr.number}}.surge.sh.

Multiple Jobs

name: ๐Ÿ”‚ Surge PR Preview

on: [pull_request]

permissions:
  pull-requests: write # allow surge-preview to create/update PR comments

jobs:
  preview-job-1:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: afc163/surge-preview@v1
        with:
          surge_token: ${{ secrets.SURGE_TOKEN }}
          dist: public
          build: |
            npm install
            npm run build
  preview-job-2:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - uses: afc163/surge-preview@v1
        with:
          surge_token: ${{ secrets.SURGE_TOKEN }}
          dist: public
          build: |
            npm install
            npm run build

The preview website urls will be:

  • https://{{repository.owner}}-{{repository.name}}-preview-job-1-pr-{{pr.number}}.surge.sh
  • https://{{repository.owner}}-{{repository.name}}-preview-job-2-pr-{{pr.number}}.surge.sh

Teardown

When a pull request is closed and teardown is set to 'true', then the surge instance will be destroyed.

name: ๐Ÿ”‚ Surge PR Preview

on:
  pull_request:
    # when using teardown: 'true', add default event types + closed event type
    types: [opened, synchronize, reopened, closed]
  push:

jobs:
  preview:
    runs-on: ubuntu-latest
    permissions:
      pull-requests: write # allow surge-preview to create/update PR comments
    steps:
      - uses: actions/checkout@v2
      - uses: afc163/surge-preview@v1
        with:
          surge_token: ${{ secrets.SURGE_TOKEN }}
          dist: public
          teardown: 'true'
          build: |
            npm install
            npm run build

Inputs

  • surge_token: Getting your Surge token.
  • github_token: Defaults: github.token. It is used to create Pull Request comment, so it requires the pull-requests permission set to write permission. Possible value: secrets.GITHUB_TOKEN.
  • build: build scripts to run before deploy.
  • dist: dist folder deployed to surge.sh.
  • failOnError: Set failed if a deployment throws error, defaults to false.
  • teardown: Determines if the preview instance will be torn down on PR close, defaults to false.

Outputs

  • preview_url: The url for the related PR preview

Who are using it?

Thanks to

More Repositories

1

fanyi

A ๐Ÿ‡จ๐Ÿ‡ณ and ๐Ÿ‡บ๐Ÿ‡ธ translate tool in your command line.
JavaScript
1,315
star
2

exeq

๐Ÿ”€ Excute shell commands in queue
JavaScript
103
star
3

sketch-awesome-plugins

๐ŸŽจ ไธ€ๅฅ—ไธ้”™็š„ Sketch3 ๆ’ไปถๅˆ้›†ใ€‚
Shell
73
star
4

afc163

55
star
5

array-tree-filter

filter in array tree
JavaScript
54
star
6

MiniblogImgPop

๐Ÿ—ป ๅพฎๅšๆตฎๅ›พๆŽงไปถ
JavaScript
37
star
7

cmdize

Convert normal js to CMD module
JavaScript
36
star
8

npm-clean

Clean unused dependenices in package.json
JavaScript
22
star
9

confirm-cli

A confirm interface in command line
JavaScript
19
star
10

wa

A super convenience watch and upload tool.
JavaScript
19
star
11

color3d

Display color spaces with three.js
JavaScript
18
star
12

cdn

Upload your files to cdn
JavaScript
16
star
13

grunt-peaches

The Grunt task for peaches.
JavaScript
10
star
14

homebrew

10
star
15

dva-logger

redux-logger plugin for dva.
JavaScript
10
star
16

word-color

Color your words!
JavaScript
9
star
17

es-dev-server-react

JavaScript
8
star
18

dora-plugin-upload

dora plugin for mocking file upload
JavaScript
8
star
19

chrome

Open chrome in shell
JavaScript
7
star
20

afc163.github.io

blog
HTML
6
star
21

dotfiles

Shell
5
star
22

Cold

ๅ…ด่ถฃๅฏผๅ‘็š„็งไบบ็š„็ ”็ฉถๆ€ง่ดจ็š„ๅ‰็ซฏJSๆก†ๆžถใ€‚
JavaScript
5
star
23

snakeGame

How time flies!
JavaScript
3
star
24

ued.alipay.com

alipay ued site.
JavaScript
3
star
25

svn-sync

Get svn info object synchronously.
JavaScript
2
star
26

react-dapp

JavaScript
2
star
27

myapp

react ๆต‹่ฏ• demo ๅทฅ็จ‹
JavaScript
2
star
28

github-action-test

JavaScript
2
star
29

whoami

Who am I
JavaScript
2
star
30

now

spm package example
JavaScript
2
star
31

elasticsearch-package

Package same as:
Shell
2
star
32

cloudflare-worker-demo

JavaScript
1
star
33

ant-react-form-list

JavaScript
1
star
34

husky-test

1
star
35

monster

JavaScript
1
star
36

antd-pro-aliyun-theme

JavaScript
1
star