Skip to content

netlify_deploy_preview #289

netlify_deploy_preview

netlify_deploy_preview #289

# runs when netlify_build_docs is completed
# reason for the split: we do not want to run user code in an environment that has access to netlify secrets
name: netlify_deploy_preview
on:
workflow_run:
workflows:
- netlify_build_docs
types:
- completed
jobs:
deploy:
name: Deploy Preview
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: potiuk/get-workflow-origin@v1_1
id: source-run-info
with:
token: ${{ secrets.GITHUB_TOKEN }}
sourceRunId: ${{ github.event.workflow_run.id }}
- run: echo sourceHeadSha = ${{ steps.source-run-info.outputs.sourceHeadSha }}
- name: Set env
run: echo "GITHUB_SHA_SHORT=$(echo ${{ steps.source-run-info.outputs.sourceHeadSha }} | cut -c 1-20)" >> $GITHUB_ENV
- run: echo Short hash = ${{ env.GITHUB_SHA_SHORT }}
- name: Show pending status check
uses: Sibz/github-status-action@v1.1.5
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: Netlify preview
sha: ${{ steps.source-run-info.outputs.sourceHeadSha }}
description: Deploying site to Netlify. Please wait...
state: pending
- run: rm -rf docs
- name: 'Download artifacts'
uses: dawidd6/action-download-artifact@v2
with:
github_token: ${{secrets.GITHUB_TOKEN}}
workflow: netlify_build_docs.yml # Name of the workflow that created the artifact
name: "build-${{ steps.source-run-info.outputs.sourceHeadSha }}" # Name of the artifact
path: docs/
- run: echo Deploy Alias = ${{ env.GITHUB_SHA_SHORT }}
- uses: jsmrcaga/action-netlify-deploy@master
with:
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }}
deploy_alias: ${{ env.GITHUB_SHA_SHORT }}
build_directory: docs/
install_command: ls
build_command: ls
- name: Status check
uses: Sibz/github-status-action@v1.1.5
with:
authToken: ${{ secrets.GITHUB_TOKEN }}
context: Netlify preview
description: Click link to preview β‡’
sha: ${{ steps.source-run-info.outputs.sourceHeadSha }}
state: success
# customize with netlify site name
target_url: https://${{ env.GITHUB_SHA_SHORT }}--nimib.netlify.app