Skip to content

Commit

Permalink
Remove deploy specific outputs from action
Browse files Browse the repository at this point in the history
Added a recipe for parsing when using the `--json` flag
  • Loading branch information
South-Paw committed Sep 13, 2023
1 parent 39cf4cf commit 2a090aa
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 35 deletions.
12 changes: 0 additions & 12 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ jobs:
- name: Action outputs
run: |
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
deploy-prod-original:
name: production via netlify/actions/cli@master
Expand All @@ -53,9 +50,6 @@ jobs:
- name: Action outputs
run: |
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
deploy-draft-new:
name: draft via South-Paw/action-netlify-cli
Expand Down Expand Up @@ -84,9 +78,6 @@ jobs:
- name: Action outputs
run: |
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
deploy-prod-new:
name: production via South-Paw/action-netlify-cli
Expand Down Expand Up @@ -115,6 +106,3 @@ jobs:
- name: Action outputs
run: |
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
6 changes: 0 additions & 6 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,6 @@ jobs:
- name: Action outputs
run: |
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
deploy-prod-new:
name: production
Expand All @@ -59,6 +56,3 @@ jobs:
- name: Action outputs
run: |
echo "NETLIFY_OUTPUT: ${{ steps.netlify.outputs.NETLIFY_OUTPUT }}"
echo "NETLIFY_LOGS_URL: ${{ steps.netlify.outputs.NETLIFY_LOGS_URL }}"
echo "NETLIFY_DRAFT_URL: ${{ steps.netlify.outputs.NETLIFY_DRAFT_URL }}"
echo "NETLIFY_PROD_URL: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}"
46 changes: 38 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,6 @@ This action usually completes in under a minute (and in best cases, 30s).
The following outputs will be available from a step that uses this action:

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

## Recipes

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

- name: Publish
uses: South-Paw/action-netlify-cli@1.0.1
uses: South-Paw/action-netlify-cli@v2
id: netlify
with:
# be sure to escape any double quotes with a backslash and note that the --json
# flag has been passed when deploying - if you want the outputs to work you'll need to include it
# 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 }}
Expand All @@ -64,9 +60,10 @@ jobs:
# ... steps to build your site for deployment

- name: Deploy to Netlify
uses: South-Paw/action-netlify-cli@1.0.1
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 }}
Expand All @@ -80,7 +77,40 @@ jobs:
step: finish
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
env_url: ${{ steps.netlify.outputs.NETLIFY_PROD_URL }}
env_url: ${{ fromJson(steps.netlify.outputs.NETLIFY_OUTPUT).url }}
```
### Parse `--json` flag

```yml
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 }}"
```
## Issues and Bugs
Expand Down
9 changes: 0 additions & 9 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,3 @@ outputs:
NETLIFY_OUTPUT:
description: "Raw Netlify CLI output message"
value: ${{ steps.script.outputs.NETLIFY_OUTPUT }}
NETLIFY_LOGS_URL:
description: "URL to Netlify deployment logs"
value: ${{ fromJson(steps.script.outputs.NETLIFY_OUTPUT).logs }}
NETLIFY_DRAFT_URL:
description: "URL to draft site"
value: ${{ fromJson(steps.script.outputs.NETLIFY_OUTPUT).deploy_url }}
NETLIFY_PROD_URL:
description: "URL to production site"
value: ${{ fromJson(steps.script.outputs.NETLIFY_OUTPUT).url }}

0 comments on commit 2a090aa

Please sign in to comment.