Skip to content

Commit 2a090aa

Browse files
committed
Remove deploy specific outputs from action
Added a recipe for parsing when using the `--json` flag
1 parent 39cf4cf commit 2a090aa

File tree

4 files changed

+38
-35
lines changed

4 files changed

+38
-35
lines changed

.github/workflows/benchmark.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,6 @@ jobs:
2828
- name: Action outputs
2929
run: |
3030
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
31-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
32-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
33-
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
3431
3532
deploy-prod-original:
3633
name: production via netlify/actions/cli@master
@@ -53,9 +50,6 @@ jobs:
5350
- name: Action outputs
5451
run: |
5552
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
56-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
57-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
58-
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
5953
6054
deploy-draft-new:
6155
name: draft via South-Paw/action-netlify-cli
@@ -84,9 +78,6 @@ jobs:
8478
- name: Action outputs
8579
run: |
8680
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
87-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
88-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
89-
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
9081
9182
deploy-prod-new:
9283
name: production via South-Paw/action-netlify-cli
@@ -115,6 +106,3 @@ jobs:
115106
- name: Action outputs
116107
run: |
117108
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
118-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
119-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
120-
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"

.github/workflows/ci.yaml

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,6 @@ jobs:
3131
- name: Action outputs
3232
run: |
3333
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
34-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
35-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
36-
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
3734
3835
deploy-prod-new:
3936
name: production
@@ -59,6 +56,3 @@ jobs:
5956
- name: Action outputs
6057
run: |
6158
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
62-
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
63-
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
64-
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: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -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)