|
31 | 31 | with: |
32 | 32 | name: docs-html |
33 | 33 | path: docs/_site |
| 34 | + # push to netlify ------------------------------------------------------- |
| 35 | + |
| 36 | + # set release name ---- |
| 37 | + |
| 38 | + - name: Configure pull release name |
| 39 | + if: ${{github.event_name == 'pull_request'}} |
| 40 | + run: | |
| 41 | + echo "RELEASE_NAME=pr-${PR_NUMBER}" >> $GITHUB_ENV |
| 42 | + env: |
| 43 | + PR_NUMBER: ${{ github.event.number }} |
| 44 | + - name: Configure branch release name |
| 45 | + if: ${{github.event_name != 'pull_request'}} |
| 46 | + run: | |
| 47 | + # use branch name, but replace slashes. E.g. feat/a -> feat-a |
| 48 | + echo "RELEASE_NAME=${GITHUB_REF_NAME/\//-}" >> $GITHUB_ENV |
| 49 | + # deploy ---- |
| 50 | + |
| 51 | + - name: Create Github Deployment |
| 52 | + uses: bobheadxi/deployments@v0.4.3 |
| 53 | + id: deployment |
| 54 | + with: |
| 55 | + step: start |
| 56 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + env: ${{ env.RELEASE_NAME }} |
| 58 | + ref: ${{ github.head_ref }} |
| 59 | + transient: true |
| 60 | + logs: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
| 61 | + |
| 62 | + - name: Netlify docs preview |
| 63 | + run: | |
| 64 | + npm install -g netlify-cli |
| 65 | + # push main branch to production, others to preview -- |
| 66 | + if [ "${ALIAS}" == "main" ]; then |
| 67 | + netlify deploy --dir=docs/_site --alias="main" |
| 68 | + else |
| 69 | + netlify deploy --dir=docs/_site --alias="${ALIAS}" |
| 70 | + fi |
| 71 | + env: |
| 72 | + NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} |
| 73 | + NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} |
| 74 | + ALIAS: ${{ steps.deployment.outputs.env }} |
| 75 | + |
| 76 | + - name: Update Github Deployment |
| 77 | + uses: bobheadxi/deployments@v0.4.3 |
| 78 | + if: ${{ always() }} |
| 79 | + with: |
| 80 | + step: finish |
| 81 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 82 | + status: ${{ job.status }} |
| 83 | + deployment_id: ${{ steps.deployment.outputs.deployment_id }} |
| 84 | + env_url: 'https://${{ steps.deployment.outputs.env }}--relaxed-mooncake-704252.netlify.app' |
| 85 | + logs: 'https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}' |
| 86 | + |
34 | 87 | - name: publish dev docs |
35 | 88 | if: github.ref_name == 'main' && github.ref_type == 'branch' |
36 | 89 | uses: peaceiris/actions-gh-pages@v3 |
|
0 commit comments