• This repository has been archived on 08/Sep/2021
  • Stars
    star
    178
  • Rank 214,989 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created over 8 years ago
  • Updated over 3 years ago

Reviews

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

Repository Details

Build Status

netlifyctl

Legacy command line interface for managing and deploying sites on Netlify without leaving your terminal. Built in Go, on Netlify's OpenAPI definitions to interact with Netlify's API.

Netlify continues to support this version, but active development has moved to our new Node-based CLI. Find the full documentation at netlify.com/docs/cli.

Installation

Homebrew (Mac)

If you're running the Homebrew package manager for Mac, you can install netlifyctl with the following commands:

brew tap netlify/netlifyctl
brew install netlifyctl

When your installation completes, you can run netlifyctl --help for a list of available commands, or refer to this doc for more details.

Scoop (Windows)

Scoop is a package manager for Windows. You can install it with a single PowerShell command, then use it to install other command-line tools. To install netlifyctl using Scoop, run the following commands:

scoop bucket add netlifyctl https://github.com/netlify/scoop-netlifyctl
scoop install netlifyctl

When your installation completes, you can run netlifyctl --help for a list of available commands, or refer to this doc for more details.

Direct Binary Install (Linux, Mac, Windows)

Because netlifyctl is released as an executable binary file, you can download, extract, and run it from any directory you choose, with no dependencies.

You can download the latest version for your operating system directly from the following links:

If you're working on a local machine with administrator permissions, you may want to add netlifyctl to your PATH, so that you can access it directly from any project folder. You could do this by extracting it to a directory that is already on your PATH. (For example, /usr/local/bin is a common choice for Mac and Linux.) Alternatively, you can extract the netlifyctl binary to a different folder, then follow your operating system instructions for adding a path to your PATH environment variable.

In cases where you can't or don't want to install globally, like in many Continuous Integration (CI) environments, you can run netlifyctl from the folder of your choice by calling the path to the binary file.

For example, you could run the following command to download and extract the binary file directly into the current directory in a Linux terminal:

wget -qO- 'https://cli.netlify.com/download/latest/linux' | tar xz

Then, to use netlifyctl in that directory, you would use the relative path to the binary: ./netlifyctl. All netlifyctl commands in the rest of this document would follow the same pattern, for example:

./netlifyctl --help

Installing from Source with go get

Use the following commands to install netlifyctl from source:

go get -d github.com/netlify/netlifyctl
cd $GOPATH/src/github.com/netlify/netlifyctl
make deps build
go install

Authentication

Netlifyctl uses an access token to authenticate with Netlify. You can obtain this token via the command line or in the Netlify UI.

Command-line Login

To authenticate and obtain an access token via the command line, enter the following command:

netlifyctl login

This will open a browser window, asking you to log in with Netlify and grant access to Netlify Cli.

Once authorized, netlifyctl will store your access token in your home folder, under .config/netlify. Netlifyctl will use the token in this location automatically for all future commands.

If you'd like to store your token in a different location, you can remove it from the default location and add it manually to your commands by using the -A flag:

netlifyctl -A "YOUR_ACCESS_TOKEN" deploy

If you lose your token, you can repeat this process to generate a new one.

Obtain a Token in the Netlify UI

You can generate an access token manually in your Netlify account settings under OAuth applications, at https://app.netlify.com/applications.

  1. Under Personal access tokens, select New access token.
  2. Enter a description and select Generate token.
  3. Copy the generated token to your clipboard. Once you navigate from the page, the token cannot be seen again.

You can add the access token to individual commands with the -A flag:

netlifyctl -A "YOUR_ACCESS_TOKEN" deploy

Alternatively, you can store the token locally, and netlifyctl will use it automatically. To do this, enter the following line in a file titled netlify:

{"access_token": "YOUR_ACCESS_TOKEN"}

Store the file in a folder called .config, inside your home folder.

Revoking Access

To revoke access to your account for netlifyctl, go to the OAuth applications section of your account settings, at https://app.netlify.com/applications. Find the appropriate token or application, and select Revoke.

Continuous Deployment

With continuous deployment, Netlify will automatically deploy new versions of your site when you push commits to your connected Git repository. This also enables features like Deploy Previews, branch deploys, and split testing. (Some of these features must be enabled in the Netlify UI.)

Automated Setup

For repositories stored on GitHub or GitLab, you can use netlifyctl to connect your repository by running the following command from your local repository:

netlifyctl init

In order to connect your repository for continuous deployment, netlifyctl will need access to create a deploy key and a webhook on the repository. When you run the command above, you'll be prompted to log in to your GitHub account, which will create an account-level access token.

The access token will be stored in your home folder, under .config/hub. Your login password will never be stored. You can revoke the access token at any time from your GitHub account settings.

Manual Setup

For repositories stored on other Git providers, or if you prefer to give more limited, repository-only access, you can connect your repository manually by adding the --manual flag. From your local repository, run the following command:

netlifyctl init --manual

The tool will prompt you for your deploy settings, then provide you with two items you will need to add to your repository settings with your Git provider:

  • Deploy/access key: Netlify uses this key to fetch your repository via ssh for building and deploying. Sample terminal output reads: 'Give this Netlify SSH public key access to your repository,' and displays a key code. Copy the key printed in the command line, then add it as a deploy key in the repository settings on your Git Provider. The deploy key does not require write access. Note that if you have more than one site connected to a repo, you will need a unique key for each one.
  • Webhook: Your Git provider will send a message to this webhook when you push changes to your repository, triggering a new deploy on Netlify. Sample terminal output reads: 'Configure the following webhook for your repository,' and displays a URL. Copy the webhook address printed in the command line, then add it as the Payload URL for a new webhook in the repository settings on your Git provider. If available, the Content type should be set to application/json. When selecting events to trigger the webhook, Push events will trigger production and branch deploys on watched branches, and Pull/Merge request events will trigger deploy previews.

Manual Deploy

It's also possible to deploy a site manually, without continuous deployment. This method uploads files directly from your local project directory to your site on Netlify, without running a build step. It also works with directories that are not Git repositories.

A common use case for this command is when you're using a separate Contiuous Integration (CI) tool, deploying prebuilt files to Netlify at the end of the CI tool tasks.

To deploy manually, run the following command from the base of your project directory:

netlifyctl deploy

Netlifyctl will deploy the site using the configuration settings in a netlify.toml file stored at the base of your project directory. If this file doesn't exist, netlifyctl will prompt you for your site settings, then create a new netlify.toml file to store them.

After the first deploy, you can run netlifyctl deploy again to update your site whenever you make changes. Only new and changed files will be uploaded.

Draft Deploys

If you'd like to preview a manual deploy without changing it in production, you can use the --draft flag:

netlifyctl deploy --draft

This will run a deploy just like your production deploy, but at a unique address. The draft site URL will display in the command line when the deploy is done.

Debugging

Netlifyctl generates debug logs with all the request and response interations when there is an error running any command. Those logs are stored in a file called netlifyctl-debug.log in the directory where you ran the command. These logs include your access token for the API! Please make sure you don't share them with anyone without masking those first.

You can force the CLI to generate these logs even when there are no errors with the -D flag: netlifyctl -D deploy.

Additional Commands

For a full list of commands and global flags available with netlifyctl, run the following:

netlifyctl help

For more information about a specific command, run help with the name of the command.

netlifyctl help deploy

This also works for sub-commands.

netlifyctl help site update

License

MIT

More Repositories

1

netlify-cms

A Git-based CMS for Static Site Generators
JavaScript
16,192
star
2

gotrue

An SWT based API for managing users and issuing SWT tokens.
Go
3,530
star
3

staticgen

StaticGen.com, A leaderboard of top open-source static site generators
JavaScript
2,471
star
4

cli

Netlify Command Line Interface
TypeScript
1,576
star
5

gocommerce

A headless e-commerce for JAMstack sites.
Go
1,465
star
6

netlify-identity-widget

A zero config, framework free Netlify Identity widget
JavaScript
735
star
7

next-on-netlify

Build and deploy Next.js applications with Server-Side Rendering on Netlify!
JavaScript
720
star
8

headlesscms.org

Source for headlesscms.org
JavaScript
628
star
9

netlify-lambda

Helps building and serving lambda functions locally and in CI environments
JavaScript
601
star
10

next-runtime

The Next.js Runtime allows Next.js to run on Netlify with zero configuration
TypeScript
575
star
11

functions.netlify.com

Tutorials, examples, workshops and a playground for serverless with Netlify Functions
SCSS
515
star
12

build-image

This is the build image used for running automated builds
Shell
498
star
13

gotrue-js

JavaScript client library for GoTrue
JavaScript
457
star
14

create-react-app-lambda

JavaScript
414
star
15

netlify-faunadb-example

Using FaunaDB with netlify functions
JavaScript
388
star
16

actions

Shell
360
star
17

git-gateway

A Gateway to Git APIs
Go
355
star
18

zip-it-and-ship-it

Intelligently prepare Node.js Lambda functions for deployment
JavaScript
305
star
19

gotell

Netlify Comments is an API and build tool for handling large amounts of comments for JAMstack products
Go
276
star
20

explorers

JavaScript
262
star
21

million-devs

Microsite for the 1 Million Developers announcement.
Vue
250
star
22

netlify-statuskit

Netlify StatusKit is a template to deploy your own Status pages on Netlify.
HTML
237
star
23

open-api

Open API specification of Netlify's API
Go
234
star
24

build

Netlify Build (node process) runs the build command, Build Plugins and bundles Netlify Functions. Can be run in Buildbot or locally using Netlify CLI
JavaScript
216
star
25

js-client

A Open-API derived JS + Node.js API client for Netlify
JavaScript
214
star
26

netlify-plugin-lighthouse

Netlify Plugin to run Lighthouse on each build
JavaScript
198
star
27

netlify-dev-plugin

Local dev server with functions, rules engine and add-on support
JavaScript
176
star
28

framework-info

Framework detection utility
JavaScript
137
star
29

jekyll-srcset

Dead simple responsive images for jekyll
Ruby
136
star
30

gocommerce-js

A gocommerce client library
JavaScript
130
star
31

jekyll-gdrive

Access a Google Drive Spreadsheet from your Jekyll templates
Ruby
116
star
32

plugins

Netlify plugins directory.
JavaScript
95
star
33

prerender

Automatically rendering JS-driven pages for crawlers and social sharing
JavaScript
94
star
34

netlify-playground

89
star
35

netlify-plugin-gatsby

A build plugin to integrate Gatsby seamlessly with Netlify
TypeScript
88
star
36

code-examples

Code snippets for customers
HTML
87
star
37

labs

Documentation and samples for Netlify Labs features.
76
star
38

templates

This is board to showcase templates and boilerplates https://templates.netlify.com
Nunjucks
76
star
39

vue-cli-plugin-netlify-lambda

Netlify Lambda plugin for Vue CLI
JavaScript
76
star
40

remix-template

Deploy your Remix site to Netlify Edge Functions
JavaScript
73
star
41

netlify-cms-widget-starter

A boilerplate for creating Netlify CMS widgets.
JavaScript
73
star
42

classnames-template-literals

Small utility to format long classnames with template literals
JavaScript
70
star
43

edge-functions-examples

Explore a library of reference examples for learning about Edge Functions on Netlify.
JavaScript
70
star
44

gotiator

A tiny JWT based API gateway
Go
70
star
45

matterday.netlify.com

A site that asks us what we could do with more time.
CSS
70
star
46

react-server-components-demo

Minimal implementation on server components via Netlify functions
JavaScript
67
star
47

binrc

Binrc is a command line application to manage different versions of binaries stored on GitHub releases.
Makefile
52
star
48

next-on-netlify-demo

Demo of a Next.js app with Server-Side Rendering on Netlify
JavaScript
52
star
49

go-functions-example

Go
49
star
50

petsofnetlify

pets of netlifiers
Nunjucks
47
star
51

full-react-server-demo

JavaScript
45
star
52

rust-functions-example

Deploy Rust lambda functions on Netlify
Rust
45
star
53

gojoin

Mini API wrapping Stripes Subscriptions for Single Page Aps and JAMstack sites
Go
41
star
54

netlify-git-api

Go
41
star
55

gatsby-parallel-runner

JavaScript
38
star
56

functions

JavaScript and TypeScript utilities for Netlify Functions.
TypeScript
38
star
57

elastinats

Go
36
star
58

netlify-photo-gallery

HTML
35
star
59

gocommerce-admin

Admin UI for Netlify Commerce
JavaScript
35
star
60

addons

Netlify add-on documentation
34
star
61

ask-netlify

A place to submit questions for Netlify to answer in tutorials, podcasts and blog posts
HTML
34
star
62

netlify-auth-demo

Demo for integrating GitHub OAuth with a Netlify site
HTML
33
star
63

explorers-up-and-running-with-serverless-functions

Free resource for learning how to use serverless functions!
HTML
31
star
64

hydrogen-netlify-starter

Get started with Hydrogen on Netlify
JavaScript
31
star
65

build-plugin-template

Template repository to create new Netlify Build plugins.
JavaScript
30
star
66

twickr

Twickr lets you send tweets of interest from Twitter to Slack
Go
30
star
67

next-edge-middleware

JavaScript
29
star
68

remix-compute

Remix adapter and server runtime for Netlify
TypeScript
29
star
69

www-post-scheduler

This is a serverless function to auto publish blog posts
JavaScript
28
star
70

postcss-fout-with-a-class

Rewrite all selectors that will trigger a font load to be scoped under a class
JavaScript
28
star
71

micro-api-client

Small library for talking to micro REST APIs (not related to Netlify's main API)
JavaScript
28
star
72

vue-lambda-starter

Starter Template for Vue + AWS Lambda with Netlify
Vue
27
star
73

netlify-browser-extension

netlify-chrome-extension
JavaScript
26
star
74

make-wp-epic

Migration tool for moving from WordPress to Victor Hugo
JavaScript
26
star
75

hydrogen-platform

Hydrogen support for Netlify Edge Functions
TypeScript
26
star
76

netlify-redirect-parser

Library for parsing Netlify redirects
JavaScript
23
star
77

next-react-server-components

JavaScript
22
star
78

netlify-auth-providers

JS library to use Netlify's OAuth providers
JavaScript
22
star
79

explorers-composition-api

Learn how the Composition API works in this Jamstack Explorers mission!
Vue
20
star
80

vite-plugin-netlify-edge

Netlify Edge Function support for Vite
TypeScript
19
star
81

angular-runtime

The Angular Runtime allows Angular to run on Netlify with zero configuration
JavaScript
18
star
82

mailme

MailMe sends mails with stylish templates
Go
18
star
83

eslint-config-node

ESLint, Prettier and Editorconfig shared by Netlify's Node.js projects
JavaScript
18
star
84

slate-markdown-serializer

JavaScript
17
star
85

delta-action

A GitHub Action for capturing benchmark data and tracking its variation against a baseline
JavaScript
17
star
86

netlify-credential-helper

Git credential helper to use Netlify's API as authentication backend
Go
16
star
87

blobs

A TypeScript client for Netlify Blobs
TypeScript
16
star
88

netlify-cms-www

Former repo for netlifycms.org. Moved to the code repo at
CSS
15
star
89

go-client

Depreciated repo: home of the old go client. See netlify/open-api for the new home of the go client
Go
15
star
90

verify-okta

Small Lambda function for verifying and gating content with Okta
Go
14
star
91

netlify-oauth-example

JavaScript
14
star
92

godoc-static

Generates static HTML of documentation of Go libraries
Go
13
star
93

fauna-one-click

Moved https://github.com/netlify/netlify-faunadb-example
JavaScript
13
star
94

screenshot

Take screenshots of websites
Shell
13
star
95

netlify-comments-starter

Start project for Netlify Comments
13
star
96

node-template

Netlify's Node.js repository template
Python
13
star
97

streamer

tail files and send them to nats
Go
12
star
98

edge-bundler

Intelligently prepare Netlify Edge Functions for deployment
TypeScript
12
star
99

ruby-client

Netlify API client for Ruby
Ruby
11
star
100

gatsby-plugin-netlify

Gatsby plugin. Automatically generates a _headers file and a _redirects file at the root of the public folder to configure HTTP headers and redirects on Netlify.
TypeScript
11
star