diff --git a/.github/workflows/benchmark.yaml b/.github/workflows/benchmark.yaml index bbf8825..faf3514 100644 --- a/.github/workflows/benchmark.yaml +++ b/.github/workflows/benchmark.yaml @@ -4,6 +4,7 @@ on: push: branches: - "main" + workflow_dispatch: jobs: deploy-draft-original: @@ -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 @@ -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 "
$(date -u)\n$GITHUB_SHA\n$GITHUB_REF" > 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 }}]\"' @@ -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 "
$(date -u)\n$GITHUB_SHA\n$GITHUB_REF" > 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 }}]\"' @@ -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 }}" diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index f4153f9..181ce44 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -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 "
$(date -u)\n$GITHUB_SHA\n$GITHUB_REF" > 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 }}]\"' @@ -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 "
$(date -u)\n$GITHUB_SHA\n$GITHUB_REF" > 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 }}]\"' @@ -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 }}" diff --git a/README.md b/README.md index a8ebad8..2fe4f47 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 }} @@ -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 }} @@ -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 diff --git a/action.yml b/action.yml index 7e93c3f..33c61f3 100644 --- a/action.yml +++ b/action.yml @@ -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