-
Notifications
You must be signed in to change notification settings - Fork 0
/
action.yaml
78 lines (66 loc) · 2.25 KB
/
action.yaml
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
name: VisWiz Build
description: Creates a new build on VisWiz.io.
author: VisWiz.io
inputs:
api-key:
description: The API key to use when creating a new build
required: true
images-directory:
description: The folder containing the images for the new build
required: true
project-id:
description: The project ID containing the new build
required: true
server-url:
description: The VisWiz.io server URL
required: false
default: https://api.viswiz.io
branding:
color: green
icon: check-circle
runs:
using: "composite"
steps:
- run: |
BRANCH_NAME="${{ github.ref }}"
COMMIT_SHA="${{ github.sha }}"
if [[ "$GITHUB_EVENT_NAME" == "pull_request" ]]; then
BRANCH_NAME="${{ github.head_ref }}"
COMMIT_SHA="${{ github.event.pull_request.head.sha }}"
fi
echo "branch_name=${BRANCH_NAME##refs/heads/}" >> $GITHUB_OUTPUT
echo "commit_message=$(git log --format=%s -n 1 $COMMIT_SHA)" >> $GITHUB_OUTPUT
echo "commit_sha=$COMMIT_SHA" >> $GITHUB_OUTPUT
echo "viswiz_version=2" >> $GITHUB_OUTPUT
shell: bash
id: vars
- uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
id: setup-node
with:
node-version: '18'
# https://stackoverflow.com/a/42636741
- run: |
echo "::group::Creating new viswiz build"
pnpm -v
exec {stdout_copy}>&1
OUTPUT=$(pnpm dlx viswiz@${{ steps.vars.outputs.viswiz_version }} build \
--branch "${{ steps.vars.outputs.branch_name }}" \
--image-dir "${{ inputs.images-directory }}" \
--message "${{ steps.vars.outputs.commit_message }}" \
--project "${{ inputs.project-id }}" \
--revision "${{ steps.vars.outputs.commit_sha }}" | tee /dev/fd/$stdout_copy)
exec {stdout_copy}>&-
echo "::endgroup::"
for LINE in $OUTPUT; do
if [[ "$LINE" =~ .*app.viswiz.io.* ]]; then
echo "### VisWiz.io Report" >> $GITHUB_STEP_SUMMARY
echo ":eyes: [View full report]($LINE)" >> $GITHUB_STEP_SUMMARY
fi
done
shell: bash
env:
VISWIZ_API_KEY: ${{ inputs.api-key }}
VISWIZ_SERVER: ${{ inputs.server-url }}