Skip to content

Commit 0e5db32

Browse files
authored
Merge pull request #4 from South-Paw/remove-json-parsing
Remove JSON parsing
2 parents 2f244b2 + 2a090aa commit 0e5db32

File tree

4 files changed

+60
-43
lines changed

4 files changed

+60
-43
lines changed

.github/workflows/benchmark.yaml

Lines changed: 11 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ on:
44
push:
55
branches:
66
- "main"
7+
workflow_dispatch:
78

89
jobs:
910
deploy-draft-original:
@@ -27,9 +28,6 @@ jobs:
2728
- name: Action outputs
2829
run: |
2930
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
30-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
31-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
32-
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
3331
3432
deploy-prod-original:
3533
name: production via netlify/actions/cli@master
@@ -52,24 +50,24 @@ jobs:
5250
- name: Action outputs
5351
run: |
5452
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
55-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
56-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
57-
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
5853
5954
deploy-draft-new:
60-
name: draft via South-Paw/action-netlify-cli@main
55+
name: draft via South-Paw/action-netlify-cli
6156
runs-on: ubuntu-latest
6257
needs:
6358
- deploy-draft-original
6459
- deploy-prod-original
6560
steps:
61+
- name: Checkout repository
62+
uses: actions/checkout@v3
63+
6664
- name: Generate HTML document
6765
run: |
6866
mkdir -p example
6967
echo -e "<pre>$(date -u)\n$GITHUB_SHA\n$GITHUB_REF</pre>" > example/index.html
7068
7169
- name: Deploy draft to Netlify
72-
uses: South-Paw/action-netlify-cli@main
70+
uses: ./
7371
id: netlify
7472
with:
7573
args: 'deploy --json --dir \"./example\" --message \"draft [${{ github.sha }}]\"'
@@ -80,24 +78,24 @@ jobs:
8078
- name: Action outputs
8179
run: |
8280
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
83-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
84-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
85-
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
8681
8782
deploy-prod-new:
88-
name: production via South-Paw/action-netlify-cli@main
83+
name: production via South-Paw/action-netlify-cli
8984
runs-on: ubuntu-latest
9085
needs:
9186
- deploy-draft-original
9287
- deploy-prod-original
9388
steps:
89+
- name: Checkout repository
90+
uses: actions/checkout@v3
91+
9492
- name: Generate HTML document
9593
run: |
9694
mkdir -p example
9795
echo -e "<pre>$(date -u)\n$GITHUB_SHA\n$GITHUB_REF</pre>" > example/index.html
9896
9997
- name: Deploy to Netlify
100-
uses: South-Paw/action-netlify-cli@main
98+
uses: ./
10199
id: netlify
102100
with:
103101
args: 'deploy --json --prod --dir \"./example\" --message \"production [${{ github.sha }}]\"'
@@ -108,6 +106,3 @@ jobs:
108106
- name: Action outputs
109107
run: |
110108
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
111-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
112-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
113-
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"

.github/workflows/ci.yaml

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,24 @@ name: CI
33
on:
44
push:
55
branches-ignore:
6-
- "master"
6+
- "main"
7+
workflow_dispatch:
78

89
jobs:
910
deploy-draft-new:
1011
name: draft
1112
runs-on: ubuntu-latest
1213
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v3
16+
1317
- name: Generate HTML document
1418
run: |
1519
mkdir -p example
1620
echo -e "<pre>$(date -u)\n$GITHUB_SHA\n$GITHUB_REF</pre>" > example/index.html
1721
1822
- name: Deploy draft to Netlify
19-
uses: South-Paw/action-netlify-cli@main
23+
uses: ./
2024
id: netlify
2125
with:
2226
args: 'deploy --json --dir \"./example\" --message \"draft [${{ github.sha }}]\"'
@@ -27,21 +31,21 @@ jobs:
2731
- name: Action outputs
2832
run: |
2933
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
30-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
31-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
32-
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
3334
3435
deploy-prod-new:
3536
name: production
3637
runs-on: ubuntu-latest
3738
steps:
39+
- name: Checkout repository
40+
uses: actions/checkout@v3
41+
3842
- name: Generate HTML document
3943
run: |
4044
mkdir -p example
4145
echo -e "<pre>$(date -u)\n$GITHUB_SHA\n$GITHUB_REF</pre>" > example/index.html
4246
4347
- name: Deploy to Netlify
44-
uses: South-Paw/action-netlify-cli@main
48+
uses: ./
4549
id: netlify
4650
with:
4751
args: 'deploy --prod --json --dir \"./example\" --message \"production [${{ github.sha }}]\"'
@@ -52,6 +56,3 @@ jobs:
5256
- name: Action outputs
5357
run: |
5458
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
55-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
56-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
57-
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"

README.md

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,6 @@ This action usually completes in under a minute (and in best cases, 30s).
1616
The following outputs will be available from a step that uses this action:
1717

1818
- `NETLIFY_OUTPUT`, the full stdout from the run of the `netlify` command
19-
- `NETLIFY_LOGS_URL`, the URL where the logs from the deploy can be found
20-
- `NETLIFY_DRAFT_URL`, the URL of the draft site that Netlify provides
21-
- `NETLIFY_PROD_URL`, the URL of the "real" site, set only if `--prod` was passed
2219

2320
## Recipes
2421

@@ -33,11 +30,10 @@ jobs:
3330
# build your site for deployment... in this case the `public` folder is being deployed
3431

3532
- name: Publish
36-
uses: South-Paw/action-netlify-cli@1.0.1
33+
uses: South-Paw/action-netlify-cli@v2
3734
id: netlify
3835
with:
39-
# be sure to escape any double quotes with a backslash and note that the --json
40-
# flag has been passed when deploying - if you want the outputs to work you'll need to include it
36+
# be sure to escape any double quotes with a backslash
4137
args: 'deploy --json --dir \"./public\" --message \"draft [${{ github.sha }}]\"'
4238
env:
4339
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
@@ -64,9 +60,10 @@ jobs:
6460
# ... steps to build your site for deployment
6561

6662
- name: Deploy to Netlify
67-
uses: South-Paw/action-netlify-cli@1.0.1
63+
uses: South-Paw/action-netlify-cli@v2
6864
id: netlify
6965
with:
66+
# note that the --json flag has been passed so we can parse outputs
7067
args: deploy --json --prod --dir './public' --message 'production [${{ github.sha }}]'
7168
env:
7269
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
@@ -80,7 +77,40 @@ jobs:
8077
step: finish
8178
status: ${{ job.status }}
8279
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
83-
env_url: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}
80+
env_url: ${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).url }}
81+
```
82+
83+
### Parse `--json` flag
84+
85+
```yml
86+
on: [push]
87+
jobs:
88+
publish:
89+
runs-on: ubuntu-latest
90+
steps:
91+
# ... steps to build your site for deployment
92+
93+
- name: Deploy to Netlify
94+
uses: South-Paw/action-netlify-cli@v2
95+
id: netlify
96+
with:
97+
# note that the --json flag has been passed so we can parse outputs
98+
args: deploy --json --prod --dir './public' --message 'production [${{ github.sha }}]'
99+
env:
100+
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
101+
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
102+
103+
# You can parse the `NETLIFY_OUTPUT` output with `fromJson` function for the following information:
104+
- name: Parse NETLIFY_OUTPUT JSON
105+
run: |
106+
echo "The URL where the logs from the deploy can be found"
107+
echo "${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).logs }}"
108+
echo ""
109+
echo "the URL of the draft site that Netlify provides"
110+
echo "${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).deploy_url }}"
111+
echo ""
112+
echo "the URL of the "real" site, set only if `--prod` was passed"
113+
echo "${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).url }}"
84114
```
85115
86116
## Issues and Bugs

action.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name: "Netlify CLI"
2-
description: "Wraps the Netlify CLI and offers access to deploy outputs"
2+
description: "Fast Netlify CLI wrapper with output"
33
author: "Alex Gabites <https://github.com/South-Paw>"
44
branding:
55
color: purple
@@ -18,12 +18,3 @@ outputs:
1818
NETLIFY_OUTPUT:
1919
description: "Raw Netlify CLI output message"
2020
value: ${{ steps.script.outputs.NETLIFY_OUTPUT }}
21-
NETLIFY_LOGS_URL:
22-
description: "URL to Netlify deployment logs"
23-
value: ${{ fromJson(steps.script.outputs.NETLIFY_OUTPUT).logs }}
24-
NETLIFY_DRAFT_URL:
25-
description: "URL to draft site"
26-
value: ${{ fromJson(steps.script.outputs.NETLIFY_OUTPUT).deploy_url }}
27-
NETLIFY_PROD_URL:
28-
description: "URL to production site"
29-
value: ${{ fromJson(steps.script.outputs.NETLIFY_OUTPUT).url }}

0 commit comments

Comments
 (0)