Skip to content

Commit 10294b8

Browse files
cristopher-ozonejsmrcaga
authored andcommitted
fix: PR fixes
1 parent 2339912 commit 10294b8

File tree

3 files changed

+73
-86
lines changed

3 files changed

+73
-86
lines changed

README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ The inputs this action uses are:
4141
| `install_command` | `false` | Auto-detected | The (optional) command to install dependencies. Runs `yarn` when `yarn.lock` is found; `npm i` otherwise |
4242
| `build_command` | `false` | `npm run build` | The (optional) command to build static website |
4343
| `deploy_alias` | `false` | '' | (Optional) [Deployed site alias](https://cli.netlify.com/commands/deploy) |
44-
| `node_version` | `false` | '' | (Optional) Node version or other arguments passed to [nvm install](https://github.com/nvm-sh/nvm#usage) |
45-
| `use_nvm` | `false` | 'true' | (Optional) Enables you to disable nvm altogether |
4644

4745

4846
### Outputs
@@ -179,7 +177,6 @@ In case of already having the deployment ready data - we can easily skip the nvm
179177
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
180178
NETLIFY_DEPLOY_MESSAGE: "Deployed from GitHub action"
181179
NETLIFY_DEPLOY_TO_PROD: true
182-
use_nvm: false
183180
install_command: "echo Skipping installing the dependencies"
184181
build_command: "echo Skipping building the web files"
185182
```

action.yml

Lines changed: 13 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -39,14 +39,6 @@ inputs:
3939
description: Deployment Subdomain name
4040
required: false
4141
default: ""
42-
node_version:
43-
description: Node version or arguments compatible with `nvm install`
44-
required: false
45-
default: ""
46-
use_nvm:
47-
description: Enables you to disable nvm altogether
48-
required: false
49-
default: true
5042
outputs:
5143
NETLIFY_OUTPUT:
5244
description: netlify command output
@@ -59,82 +51,20 @@ outputs:
5951
runs:
6052
using: composite
6153
steps:
62-
- name: "Install node through NVM if needed"
63-
shell: bash
64-
run: |
65-
if [[ "${{ inputs.use_nvm }}" == "true" ]] && ([[ -n "${{ inputs.node_version }}" ]] || [[ -e ".nvmrc" ]])
66-
then
67-
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.2/install.sh | bash
68-
[ -s "$HOME/.nvm/nvm.sh" ] && \. "$HOME/.nvm/nvm.sh"
69-
if [[ -n "${{ inputs.node_version }}" ]]
70-
then
71-
nvm install "${{ inputs.node_version }}"
72-
else
73-
nvm install
74-
fi
75-
else
76-
echo "Node installation has been omitted"
77-
fi
78-
- name: "Run install command"
79-
shell: bash
80-
run: |
81-
if [[ -n "${{ inputs.install_command }}" ]]
82-
then
83-
${{ inputs.install_command }}
84-
elif [[ -f yarn.lock ]]
85-
then
86-
yarn
87-
else
88-
npm i
89-
fi
90-
- name: "Run build command"
91-
shell: bash
92-
run: |
93-
if [[ -n "${{ inputs.build_command }}" ]]
94-
then
95-
${{ inputs.build_command }}
96-
else
97-
npm run build
98-
fi
99-
- name: "Deploy to Netlify"
100-
shell: bash
101-
run: |
102-
export NETLIFY_SITE_ID="${{ inputs.NETLIFY_SITE_ID }}"
103-
export NETLIFY_AUTH_TOKEN="${{ inputs.NETLIFY_AUTH_TOKEN }}"
104-
105-
COMMAND="netlify deploy --dir=${{ inputs.build_directory }} --functions=${{ inputs.functions_directory }} --message=\"${{ inputs.NETLIFY_DEPLOY_MESSAGE }}\""
106-
107-
if [[ "${{ inputs.NETLIFY_DEPLOY_TO_PROD }}" == "true" ]]
108-
then
109-
COMMAND+=" --prod"
110-
elif [[ -n "${{ inputs.deploy_alias }}" ]]
111-
then
112-
COMMAND+=" --alias ${{ inputs.deploy_alias }}"
113-
fi
114-
115-
# Deploy with netlify
116-
OUTPUT=$(sh -c "$COMMAND")
117-
118-
NETLIFY_OUTPUT=$(echo "$OUTPUT")
119-
NETLIFY_PREVIEW_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*(--)[a-zA-Z0-9./?=_-]*') #Unique key: --
120-
NETLIFY_LOGS_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://app.netlify.com/[a-zA-Z0-9./?=_-]*') #Unique key: app.netlify.com
121-
NETLIFY_LIVE_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*' | grep -Eov "netlify.com") #Unique key: don't containr -- and app.netlify.com
122-
123-
echo "NETLIFY_OUTPUT<<EOF" >> $GITHUB_ENV
124-
echo "$NETLIFY_OUTPUT" >> $GITHUB_ENV
125-
echo "EOF" >> $GITHUB_ENV
126-
127-
echo "NETLIFY_PREVIEW_URL<<EOF" >> $GITHUB_ENV
128-
echo "$NETLIFY_PREVIEW_URL" >> $GITHUB_ENV
129-
echo "EOF" >> $GITHUB_ENV
130-
131-
echo "NETLIFY_LOGS_URL<<EOF" >> $GITHUB_ENV
132-
echo "$NETLIFY_LOGS_URL" >> $GITHUB_ENV
133-
echo "EOF" >> $GITHUB_ENV
54+
- run: ${{ github.action_path }}/entrypoint.sh
55+
shell: bash
56+
env:
57+
NETLIFY_AUTH_TOKEN: ${{ inputs.NETLIFY_AUTH_TOKEN }}
58+
NETLIFY_SITE_ID: ${{ inputs.NETLIFY_SITE_ID }}
59+
NETLIFY_DEPLOY_TO_PROD: ${{ inputs.NETLIFY_DEPLOY_TO_PROD }}
60+
NETLIFY_DEPLOY_MESSAGE: ${{ inputs.NETLIFY_DEPLOY_MESSAGE }}
61+
BUILD_DIRECTORY: ${{ inputs.build_directory }}
62+
FUNCTIONS_DIRECTORY: ${{ inputs.functions_directory }}
63+
INSTALL_COMMAND: ${{ inputs.install_command }}
64+
BUILD_COMMAND: ${{ inputs.build_command }}
65+
DEPLOY_ALIAS: ${{ inputs.deploy_alias }}
13466

135-
echo "NETLIFY_LIVE_URL<<EOF" >> $GITHUB_ENV
136-
echo "$NETLIFY_LIVE_URL" >> $GITHUB_ENV
137-
echo "EOF" >> $GITHUB_ENV
67+
13868
branding:
13969
icon: activity
14070
color: blue

entrypoint.sh

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Run install command
6+
if [[ -n "${INSTALL_COMMAND}" ]]
7+
then
8+
${INSTALL_COMMAND}
9+
elif [[ -f yarn.lock ]]
10+
then
11+
yarn
12+
else
13+
npm i
14+
fi
15+
16+
# Run build command
17+
if [[ -n "${BUILD_COMMAND}" ]]
18+
then
19+
${BUILD_COMMAND}
20+
else
21+
npm run build
22+
fi
23+
24+
# Deploy to Netlify
25+
export NETLIFY_SITE_ID="${NETLIFY_SITE_ID}"
26+
export NETLIFY_AUTH_TOKEN="${NETLIFY_AUTH_TOKEN}"
27+
28+
COMMAND="netlify deploy --dir=${BUILD_DIRECTORY} --functions=${FUNCTIONS_DIRECTORY} --message=\"${NETLIFY_DEPLOY_MESSAGE}\""
29+
30+
if [[ "${NETLIFY_DEPLOY_TO_PROD}" == "true" ]]
31+
then
32+
COMMAND+=" --prod"
33+
elif [[ -n "${DEPLOY_ALIAS}" ]]
34+
then
35+
COMMAND+=" --alias ${DEPLOY_ALIAS}"
36+
fi
37+
38+
OUTPUT=$(sh -c "$COMMAND")
39+
40+
# Set outputs
41+
NETLIFY_OUTPUT=$(echo "$OUTPUT")
42+
NETLIFY_PREVIEW_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*(--)[a-zA-Z0-9./?=_-]*') #Unique key: --
43+
NETLIFY_LOGS_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://app.netlify.com/[a-zA-Z0-9./?=_-]*') #Unique key: app.netlify.com
44+
NETLIFY_LIVE_URL=$(echo "$OUTPUT" | grep -Eo '(http|https)://[a-zA-Z0-9./?=_-]*' | grep -Eov "netlify.com") #Unique key: don't containr -- and app.netlify.com
45+
46+
echo "NETLIFY_OUTPUT<<EOF" >> $GITHUB_ENV
47+
echo "$NETLIFY_OUTPUT" >> $GITHUB_ENV
48+
echo "EOF" >> $GITHUB_ENV
49+
50+
echo "NETLIFY_PREVIEW_URL<<EOF" >> $GITHUB_ENV
51+
echo "$NETLIFY_PREVIEW_URL" >> $GITHUB_ENV
52+
echo "EOF" >> $GITHUB_ENV
53+
54+
echo "NETLIFY_LOGS_URL<<EOF" >> $GITHUB_ENV
55+
echo "$NETLIFY_LOGS_URL" >> $GITHUB_ENV
56+
echo "EOF" >> $GITHUB_ENV
57+
58+
echo "NETLIFY_LIVE_URL<<EOF" >> $GITHUB_ENV
59+
echo "$NETLIFY_LIVE_URL" >> $GITHUB_ENV
60+
echo "EOF" >> $GITHUB_ENV

0 commit comments

Comments
 (0)