Preview deploy #2065
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| --- | |
| # Copyright (c) 2021 Red Hat, Inc. | |
| # This program and the accompanying materials are made | |
| # available under the terms of the Eclipse Public License 2.0 | |
| # which is available at https://www.eclipse.org/legal/epl-2.0/ | |
| # | |
| # SPDX-License-Identifier: EPL-2.0 | |
| # | |
| name: Preview deploy | |
| on: | |
| workflow_run: | |
| workflows: | |
| - Preview build | |
| types: | |
| - completed | |
| jobs: | |
| success: | |
| name: Preview deploy | |
| runs-on: ubuntu-latest | |
| if: github.event.workflow_run.event == 'pull_request' | |
| steps: | |
| - name: Download preview-build artifact | |
| uses: dawidd6/action-download-artifact@4c1e823582f43b179e2cbb49c3eade4e41f992e2 # v10 | |
| with: | |
| workflow: ${{ github.event.workflow_run.workflow_id }} | |
| name: preview-build | |
| allow_forks: true | |
| search_artifacts: true | |
| - name: Set variables | |
| id: vars | |
| run: | | |
| echo "pr_number=$(cat PR_NUMBER)" >> $GITHUB_OUTPUT | |
| echo "pr_sha=$(cat PR_SHA)" >> $GITHUB_OUTPUT | |
| echo "deploy_domain=$(echo ${{ github.repository }}-$(cat PR_NUMBER).surge.sh | sed 's#/#-#')" >> $GITHUB_OUTPUT | |
| - name: Deploy | |
| id: deploy | |
| env: | |
| SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} | |
| run: | | |
| # mkdocs build is in public/ | |
| npx surge --project public --domain ${{ steps.vars.outputs.deploy_domain }} --token ${{ secrets.SURGE_TOKEN }} | |
| - name: Update status Comment | |
| uses: actions-cool/maintain-one-comment@4b2dbf086015f892dcb5e8c1106f5fccd6c1476b # v3.2.0 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| body: | | |
| 🎊 Navigate the preview: https://${{ steps.vars.outputs.deploy_domain }} 🎊 | |
| <!-- Sticky Pull Request Comment --> | |
| body-include: "<!-- Sticky Pull Request Comment -->" | |
| number: ${{ steps.vars.outputs.pr_number }} | |
| - name: Job failure | |
| if: ${{ failure() }} | |
| uses: actions-cool/maintain-one-comment@4b2dbf086015f892dcb5e8c1106f5fccd6c1476b # v3.2.0 | |
| with: | |
| token: ${{ secrets.GITHUB_TOKEN }} | |
| body: | | |
| Deploy PR Preview failed. | |
| <!-- Sticky Pull Request Comment --> | |
| body-include: "<!-- Sticky Pull Request Comment -->" | |
| number: ${{ steps.vars.outputs.pr_number }} |