forked from redhat-documentation/vale-at-red-hat
-
Notifications
You must be signed in to change notification settings - Fork 0
58 lines (58 loc) · 2.12 KB
/
preview-deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
# 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@v3
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: preview-build
- 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/[email protected]
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/[email protected]
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 }}