Skip to content

Commit

Permalink
Merge pull request #4 from South-Paw/remove-json-parsing
Browse files Browse the repository at this point in the history
Remove JSON parsing
  • Loading branch information
South-Paw authored Sep 13, 2023
2 parents 2f244b2 + 2a090aa commit 0e5db32
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 43 deletions.
27 changes: 11 additions & 16 deletions .github/workflows/benchmark.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on:
push:
branches:
- "main"
workflow_dispatch:

jobs:
deploy-draft-original:
Expand All @@ -27,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 @@ -52,24 +50,24 @@ 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@main
name: draft via South-Paw/action-netlify-cli
runs-on: ubuntu-latest
needs:
- deploy-draft-original
- deploy-prod-original
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Generate HTML document
run: |
mkdir -p example
echo -e "<pre>$(date -u)\n$GITHUB_SHA\n$GITHUB_REF</pre>" > example/index.html
- name: Deploy draft to Netlify
uses: South-Paw/action-netlify-cli@main
uses: ./
id: netlify
with:
args: 'deploy --json --dir \"./example\" --message \"draft [${{ github.sha }}]\"'
Expand All @@ -80,24 +78,24 @@ 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@main
name: production via South-Paw/action-netlify-cli
runs-on: ubuntu-latest
needs:
- deploy-draft-original
- deploy-prod-original
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Generate HTML document
run: |
mkdir -p example
echo -e "<pre>$(date -u)\n$GITHUB_SHA\n$GITHUB_REF</pre>" > example/index.html
- name: Deploy to Netlify
uses: South-Paw/action-netlify-cli@main
uses: ./
id: netlify
with:
args: 'deploy --json --prod --dir \"./example\" --message \"production [${{ github.sha }}]\"'
Expand All @@ -108,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 }}"
19 changes: 10 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,24 @@ name: CI
on:
push:
branches-ignore:
- "master"
- "main"
workflow_dispatch:

jobs:
deploy-draft-new:
name: draft
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Generate HTML document
run: |
mkdir -p example
echo -e "<pre>$(date -u)\n$GITHUB_SHA\n$GITHUB_REF</pre>" > example/index.html
- name: Deploy draft to Netlify
uses: South-Paw/action-netlify-cli@main
uses: ./
id: netlify
with:
args: 'deploy --json --dir \"./example\" --message \"draft [${{ github.sha }}]\"'
Expand All @@ -27,21 +31,21 @@ 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
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Generate HTML document
run: |
mkdir -p example
echo -e "<pre>$(date -u)\n$GITHUB_SHA\n$GITHUB_REF</pre>" > example/index.html
- name: Deploy to Netlify
uses: South-Paw/action-netlify-cli@main
uses: ./
id: netlify
with:
args: 'deploy --prod --json --dir \"./example\" --message \"production [${{ github.sha }}]\"'
Expand All @@ -52,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
11 changes: 1 addition & 10 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name: "Netlify CLI"
description: "Wraps the Netlify CLI and offers access to deploy outputs"
description: "Fast Netlify CLI wrapper with output"
author: "Alex Gabites <https://github.com/South-Paw>"
branding:
color: purple
Expand All @@ -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 0e5db32

Please sign in to comment.