Giter VIP home page Giter VIP logo

action-netlify-cli's Introduction

action-netlify-cli

This action enables arbitrary actions with the Netlify CLI

This action is a replacement for netlify/actions/cli@master without the docker layer that incurs an extra 30-50s of runner time (which seems result in an average deploy time of ~1m 30s).

This action usually completes in under a minute (and in best cases, 30s).

Secrets

Outputs

The following outputs will be available from a step that uses this action:

  • NETLIFY_OUTPUT, the full stdout from the run of the netlify command

Recipes

Simple publish

on: [push]
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      # build your site for deployment... in this case the `public` folder is being deployed

      - name: Publish
        uses: South-Paw/action-netlify-cli@v2
        id: netlify
        with:
          # be sure to escape any double quotes with a backslash
          args: 'deploy --json --dir \"./public\" --message \"draft [${{ github.sha }}]\"'
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

      # and access outputs in other steps with ${{ steps.netlify.outputs.OUTPUT_ID }}

GitHub deployments

on: [push]
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      - name: Start deployment
        uses: bobheadxi/deployments@v1
        id: deployment
        with:
          env: production
          step: start

      # ... steps to build your site for deployment

      - name: Deploy to Netlify
        uses: South-Paw/action-netlify-cli@v2
        id: netlify
        with:
          # note that the --json flag has been passed so we can parse outputs
          args: deploy --json --prod --dir './public' --message 'production [${{ github.sha }}]'
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

      - name: Finish deployment
        uses: bobheadxi/deployments@v1
        if: always()
        with:
          env: ${{ steps.deployment.outputs.env }}
          step: finish
          status: ${{ job.status }}
          deployment_id: ${{ steps.deployment.outputs.deployment_id }}
          env_url: ${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).url }}

Parse --json flag

on: [push]
jobs:
  publish:
    runs-on: ubuntu-latest
    steps:
      # ... steps to build your site for deployment

      - name: Deploy to Netlify
        uses: South-Paw/action-netlify-cli@v2
        id: netlify
        with:
          # note that the --json flag has been passed so we can parse outputs
          args: deploy --json --prod --dir './public' --message 'production [${{ github.sha }}]'
        env:
          NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
          NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}

      # You can parse the `NETLIFY_OUTPUT` output with `fromJson` function for the following information:
      - name: Parse NETLIFY_OUTPUT JSON
        run: |
          echo "The URL where the logs from the deploy can be found"
          echo "${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).logs }}"
          echo ""
          echo "the URL of the draft site that Netlify provides"
          echo "${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).deploy_url }}"
          echo ""
          echo "the URL of the "real" site, set only if `--prod` was passed"
          echo "${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).url }}"

Issues and Bugs

If you find any, please report them here so they can be squashed.

License

MIT, see the LICENSE file.

action-netlify-cli's People

Contributors

ansidev avatar south-paw avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Forkers

t-philipp calpano

action-netlify-cli's Issues

Workflow is failing without json arg

Hi,
Just to let you know that your action is falling if you don't pass the --json option in the args. I've added you a screenshot to illustrate.
image
Cheers
Florian

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.