3 Star 0 Fork 0

mirrors_limonte/action-netlify-deploy

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Netlify Deploy

This is a simple GitHub Action to deploy a static website to Netlify.

Usage

To use a GitHub action you can just reference it on your Workflow file (for more info check this article by Github)

name: 'My Workflow'

on:
  release:
    types: [published]

jobs:
  deploy:
    name: 'Deploy to Netlify'
    steps:
      - uses: jsmrcaga/action-netlify-deploy@v1.1.0
        with:
          NETLIFY_AUTH_TOKEN: ${{ secrets.MY_TOKEN_SECRET }}
          NETLIFY_DEPLOY_TO_PROD: true

Inputs

As most GitHub actions, this action requires and uses some inputs, that you define in your workflow file.

The inputs this action uses are:

Name Required Default Description
NETLIFY_AUTH_TOKEN true N/A The token needed to deploy your site (generate here)
NETLIFY_SITE_ID true N/A The site to where deploy your site (get it from the API ID on your Site Settings)
NETLIFY_DEPLOY_MESSAGE false '' An optional deploy message
build_directory false 'build' The directory where your files are built
functions_directory false N/A The (optional) directory where your Netlify functions are stored
install_command false Auto-detected The (optional) command to install dependencies. Runs yarn when yarn.lock is found; npm i otherwise
build_command false npm run build The (optional) command to build static website
deploy_alias false '' (Optional) Deployed site alias
node_version false '' (Optional) Node version or other arguments passed to nvm install

Outputs

The outputs for this action are:

NETLIFY_OUTPUT

Full output of the action

NETLIFY_PREVIEW_URL

The url of deployment preview.

NETLIFY_LOGS_URL

The url of the logs.

NETLIFY_LIVE_URL

The url of the live deployed site.

Example

Deploy to production on release

You can setup repo secrets to use in your workflows

name: 'Netlify Deploy'

on:
  release:
    types: ['published']

jobs:
  deploy:
    name: 'Deploy'
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - uses: jsmrcaga/action-netlify-deploy@master
        with:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
          NETLIFY_DEPLOY_MESSAGE: "Prod deploy v${{ github.ref }}"
          NETLIFY_DEPLOY_TO_PROD: true

Preview Deploy on pull request

name: 'Netlify Preview Deploy'

on:
  pull_request:
    types: ['opened', 'edited', 'synchronize']

jobs:
  deploy:
    name: 'Deploy'
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1
      - uses: jsmrcaga/action-netlify-deploy@master
        with:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

Use branch name to deploy

Will deploy branches as https://${branchName}--${siteName}.netlify.app.

An action is used to extract the branch name to avoid fiddling with refs/. Finally, a commit status check is added, linking to the deployed site.

Only the default branch is built for simplicity. Use a similar workflow or standard Netlify integration for the production deployment.

name: 'Netlify Previews'

on:
  push:
    branches-ignore: 
      - master

jobs:
  deploy:
    name: 'Deploy'
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v1

      # Sets the branch name as environment variable
      - uses: nelonoel/branch-name@v1.0.1
      - uses: jsmrcaga/action-netlify-deploy@master
        with:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
          deploy_alias: ${{ env.BRANCH_NAME }}
      
      # Creates a status check with link to preview
      - name: Status check
        uses: Sibz/github-status-action@v1.1.1
        with:
          authToken: ${{ secrets.GITHUB_TOKEN }}
          context: Netlify preview
          state: success
          target_url: https://${{ env.BRANCH_NAME }}--my-site.netlify.app

Selecting node version

By default, the latest node will be installed before building the application.

Use the node_version input to change the desired version. It will be passed to nvm install. Valid examples include 16.3.0, 14, or --lts.

Alternatively, create an .nvmrc file with the desired version range in your repository.

Contributors

MIT License Copyright (c) 2020 Jose Maria COLINA Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
README
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/mirrors_limonte/action-netlify-deploy.git
git@gitee.com:mirrors_limonte/action-netlify-deploy.git
mirrors_limonte
action-netlify-deploy
action-netlify-deploy
master

搜索帮助