-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaction.yml
105 lines (92 loc) · 3.7 KB
/
action.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
---
name: Netlify Deploy Site
author: Data Intuitive
description: Deploy a site to Netlify.
inputs:
auth:
description: Netlify auth token to deploy with. Generate the auth token [here](https://app.netlify.com/user/applications#personal-access-tokens).
required: true
alias:
description: |
Specifies the alias for deployment, the string at the beginning of the deploy subdomain (string).
Useful for creating predictable deployment URLs. Maximum 37 characters.
required: false
dir:
description: Specify a folder to deploy (string).
required: true
prod:
description: Whether the site should be deployed to production (boolean).
required: false
default: "false"
message:
description: A short message to include in the deploy log (string).
required: false
site:
description: A site name or ID to deploy to (string). You can retrieve the API ID on your Site Settings.
required: true
timeout:
description: Timeout to wait for deployment to finish (string).
required: false
outputs:
site-name:
description: The name of the Netlify site associated with the deployment.
value: ${{ steps.netlify-deploy.outputs.site-name }}
deploy-id:
description: A unique identifier assigned by Netlify to the deployment. It is used to track and manage the deployment, and can be used to retrieve additional information about the deployment from the Netlify API.
value: ${{ steps.netlify-deploy.outputs.deploy-id }}
deploy-url:
description: The URL of the deployed site. It indicates the URL where the deployed application can be accessed by end-users.
value: ${{ steps.netlify-deploy.outputs.deploy-url }}
logs:
description: The URL of the deployment logs. It provides detailed information about the deployment process, including any errors or warnings that occurred during the deployment.
value: ${{ steps.netlify-deploy.outputs.logs }}
runs:
using: composite
steps:
- name: Install Netlify CLI
run: which netlify &> /dev/null || npm install [email protected] -g
shell: bash
- shell: bash
id: netlify-deploy
env:
NETLIFY_AUTH_TOKEN: ${{ inputs.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ inputs.NETLIFY_SITE_ID }}
run: |
ARGS=()
# process auth
if [[ -n "${{ inputs.auth }}" ]]; then
ARGS+=("--auth=${{ inputs.auth }}")
fi
# process prod and alias
if [[ "${{ inputs.prod }}" == "true" ]]; then
ARGS+=("--prod")
elif [[ -n "${{ inputs.alias }}" ]]; then
ARGS+=("--alias=${{ inputs.alias }}")
fi
# process dir
if [[ -n "${{ inputs.dir }}" ]]; then
ARGS+=("--dir=${{ inputs.dir }}")
fi
# process message
if [[ -n "${{ inputs.message }}" ]]; then
ARGS+=("--message=${{ inputs.message }}")
fi
# process site
if [[ -n "${{ inputs.site }}" ]]; then
ARGS+=("--site=${{ inputs.site }}")
fi
# process timeout
if [[ -n "${{ inputs.timeout }}" ]]; then
ARGS+=("--timeout=${{ inputs.timeout }}")
fi
TEMP_JSON="${{runner.temp}}/output.json"
netlify deploy --json "${ARGS[@]}" > >(tee "$TEMP_JSON")
# remove non-json output
# gawk -i inplace 'BEGIN { p=0 }; /^{$/ { p=1 }; p { print $0 }; p==1 && /^}$/ { p=0 }' "$TEMP_JSON"
jq -r '"site-name=" + .site_name' "$TEMP_JSON" >> $GITHUB_OUTPUT
jq -r '"deploy-id=" + .deploy_id' "$TEMP_JSON" >> $GITHUB_OUTPUT
jq -r '"deploy-url=" + .deploy_url' "$TEMP_JSON" >> $GITHUB_OUTPUT
jq -r '"logs=" + .logs' "$TEMP_JSON" >> $GITHUB_OUTPUT
branding:
icon: arrow-up-circle
color: blue