action netlify cli
2.0.0
此操作允許使用 Netlify CLI 執行任意操作
此操作是netlify/actions/cli@master
的替代品,沒有docker 層,會產生額外 30-50 秒的運行時間(這似乎導致平均部署時間約為 1m 30s)。
此操作通常在一分鐘內完成(最好情況下為 30 秒)。
NETLIFY_AUTH_TOKEN
-必要用於身份驗證的令牌。透過 UI 取得一個NETLIFY_SITE_ID
- 您想要使用的網站的選用API 網站 ID 從 UI 取得使用此操作的步驟將提供以下輸出:
NETLIFY_OUTPUT
,執行netlify
指令的完整標準輸出 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 }}
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 }}
--json
標誌 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 }}"
如果您發現任何問題,請在這裡報告,以便將它們壓扁。
麻省理工學院,請參閱許可證文件。