netlify deploy Command Reference
Deploy a built site to Netlify as a draft or production deploy.
netlify deploy uploads a built site directory to Netlify. Without --prod it creates a draft preview URL; with --prod it publishes to the production domain.
What it does
netlify deploy uploads the contents of a publish directory (and optional functions) to Netlify, returning a unique draft URL. Adding --prod publishes the same upload to the live site instead of a draft.
Common flags and usage
- --prod: publish to the production URL instead of a draft
- --dir DIR: the built site directory to upload
- --functions DIR: directory of serverless functions to deploy
- --site ID: target site id (with NETLIFY_AUTH_TOKEN for auth)
- --message TEXT: label the deploy in the Netlify UI
- --json: machine-readable output including the deploy URL
Example
- name: Netlify Deploy
env:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
run: |
netlify deploy --dir=dist --prod \
--site="${NETLIFY_SITE_ID}" \
--message="ci ${{ github.sha }}"In CI
Authenticate with NETLIFY_AUTH_TOKEN and target the site with --site or NETLIFY_SITE_ID so the CLI never prompts. Deploy a draft on pull requests and reserve --prod for the deploy branch; --json lets you capture the draft URL to post back on the PR.
Key takeaways
- netlify deploy uploads a built directory; --prod publishes to production.
- Use NETLIFY_AUTH_TOKEN and --site so the CLI runs non-interactively.
- Deploy drafts on PRs and reserve --prod for the deploy branch.