Preview deploy #1820
This file contains 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@v6 | |
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=$(<PR_NUMBER)" >> $GITHUB_OUTPUT | |
echo "pr_sha=$(<PR_SHA)" >> $GITHUB_OUTPUT | |
echo "deploy_domain=$(echo ${{ github.repository }}-$(<PR_NUMBER).surge.sh | sed s#/#-#)" >> $GITHUB_OUTPUT | |
echo "project=$(find build/ -mindepth 1 -maxdepth 1 -type d)" >> $GITHUB_OUTPUT | |
- name: Deploy | |
id: deploy | |
env: | |
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }} | |
run: | | |
npx surge --project ${{ steps.vars.outputs.project }} --domain ${{ steps.vars.outputs.deploy_domain }} --token ${{ secrets.SURGE_TOKEN }} | |
- name: Update status Comment | |
uses: actions-cool/maintain-one-comment@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@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 }} |