-
Notifications
You must be signed in to change notification settings - Fork 100
84 lines (81 loc) · 3.1 KB
/
plugin-registry-pr-check-build-publish-content.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
79
80
81
82
83
84
#
# Copyright (c) 2020-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: Plugin Registry - PR check - Publish Registry Content
on:
workflow_run:
workflows: ["Plugin Registry - PR check - Build"]
types:
- completed
jobs:
publish:
# only if it's a pull request
if: github.event.workflow_run.event == 'pull_request'
name: publish
runs-on: ubuntu-22.04
steps:
- name: download dist artifact
uses: dawidd6/action-download-artifact@b59d8c6a6c5c6c6437954f470d963c0b20ea7415 #v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: plugin-registry-content-devspaces
path: content
- name: PR number
uses: dawidd6/action-download-artifact@b59d8c6a6c5c6c6437954f470d963c0b20ea7415 #v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: pull-request-number
- name: Grab pull request number
run: |
ls -la
pwd
pr_number=$(cat "PR_NUMBER")
if ! [[ "$pr_number" =~ ^[0-9]+$ ]]; then
echo "pr number invalid"
exit 1
fi
echo "PR_NUMBER=$pr_number" >> $GITHUB_ENV
- name: PR sha
uses: dawidd6/action-download-artifact@b59d8c6a6c5c6c6437954f470d963c0b20ea7415 #v2
with:
workflow: ${{ github.event.workflow_run.workflow_id }}
name: pull-request-sha
- name: Grab pull request sha1
run: |
pr_sha=$(cat "PR_SHA")
echo "PR_SHA=$pr_sha" >> $GITHUB_ENV
- uses: actions/setup-node@v3
with:
node-version: '16'
- name: publish
env:
SURGE_TOKEN: ${{ secrets.SURGE_TOKEN }}
run: |
sudo apt-get install tree
npm install -g surge
mkdir unpacked
tar zxvf content/*.tgz -C unpacked/
rm -rf ./unpacked/v3/resources/
# generate tree index on all directories
for directory in `find unpacked/ -type d`; do
(cd $directory && tree -H '.' -L 1 --noreport --charset utf-8 | sed '/<p class="VERSION">/,/<\/p>/d' > index.html)
done
# Make meta.yaml as index
for file in $(find unpacked -name 'meta.yaml' -type f); do
PARENT_DIR=$(dirname $file);
cp ${PARENT_DIR}/meta.yaml ${PARENT_DIR}/index.html
done
export DEPLOY_DOMAIN=https://pr-check-${PR_NUMBER}-devspaces-plugin-registry.surge.sh
echo "DEPLOY_DOMAIN=$DEPLOY_DOMAIN" >> $GITHUB_ENV
surge ./unpacked --domain $DEPLOY_DOMAIN
- name: 'Comment PR'
uses: actions/github-script@v6
with:
script: |
const { repo: { owner, repo } } = context;
await github.rest.repos.createCommitStatus({ owner, repo, sha: process.env.PR_SHA, state: "success", target_url: process.env.DEPLOY_DOMAIN, description: "Browse registry content live", context: "Surge" })