-
Notifications
You must be signed in to change notification settings - Fork 23
152 lines (136 loc) · 4.53 KB
/
ci.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
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
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
name: CI
on:
push:
branches: [ main ]
jobs:
#
# Build and test
#
build:
runs-on: ubuntu-latest
steps:
- name: Check out source
uses: actions/checkout@v2
- name: Build and Test
run: |
npm ci
npm run build
npm test
#
# Publish the action to the `dist` branch
#
publish_action:
runs-on: ubuntu-latest
needs: build
steps:
- name: Check out source
uses: actions/checkout@v2
- name: Check out distribution branch
uses: actions/checkout@v2
with:
ref: 'dist'
path: 'dist'
- name: Package
run: |
npm install
npm run pack
mkdir -p dist/documentation
mkdir -p dist/examples
cp action.yml dist/
cp README.md dist/
cp LICENSE.txt dist/
cp documentation/* dist/documentation/
cp examples/* dist/examples/
- name: Check for changes
id: status
run: |
source ../.github/workflows/actions.sh
if [ -n "$(git status --porcelain)" ]; then
set_output has_changes 1
fi
working-directory: dist
- name: Publish action
run: |
git add --verbose .
git config user.name 'Edward Thomson'
git config user.email '[email protected]'
git commit -m 'Update from CI' --allow-empty
git push origin dist
if: steps.status.outputs.has_changes == '1'
working-directory: dist
#
# Publish the documentation to the `gh-pages` branch
#
publish_documentation:
runs-on: ubuntu-latest
needs: publish_action
steps:
- name: Check out source
uses: actions/checkout@v2
- name: Check out documentation branch
uses: actions/checkout@v2
with:
ref: 'gh-pages'
path: 'gh-pages'
- name: Generate documentation
run: |
mkdir -p gh-pages/documentation
mkdir -p gh-pages/examples
( echo -e "---\ntitle: issue-dashboard\n---\n\n{% raw %}\n" && cat README.md && echo -e "\n{% endraw %}" ) > gh-pages/index.md
( echo -e "---\ntitle: issue-dashboard Documentation\n---\n\n{% raw %}\n" && cat documentation/README.md && echo -e "\n{% endraw %}" ) > gh-pages/documentation/index.md
cp LICENSE.txt gh-pages/
cp documentation/*.png gh-pages/documentation/
cp resources/dashboard.js gh-pages/examples/dashboard.js
cp resources/default.css gh-pages/examples/dashboard.css
# This is not an example of best practices of using this action.
# Normally, you would specify your configuration in-line to the
# uses step. To have a single source for defining examples, we'll
# read the configuration as it exists on-disk.
- name: Read configuration
id: config
run: |
source .github/workflows/actions.sh
set_output static_values "$(cat examples/static-values.yml)"
set_output issue_queries "$(cat examples/issue-queries.yml)"
set_output javascript_expressions "$(cat examples/javascript-expressions.yml)"
- name: 'Build example: static values'
uses: ethomson/issue-dashboard@dist
with:
config: |
${{ steps.config.outputs.static_values }}
token: ${{ github.token }}
- name: 'Publish example: static values'
run: mv dashboard.html gh-pages/examples/static-values.html
- name: 'Build example: issue queries'
uses: ethomson/issue-dashboard@dist
with:
config: |
${{ steps.config.outputs.issue_queries }}
token: ${{ github.token }}
- name: 'Publish example: issue queries'
run: mv dashboard.html gh-pages/examples/issue-queries.html
- name: 'Build example: JavaScript expressions'
uses: ethomson/issue-dashboard@dist
with:
config: |
${{ steps.config.outputs.javascript_expressions }}
token: ${{ github.token }}
- name: 'Publish example: JavaScript expressions'
run: mv dashboard.html gh-pages/examples/javascript-expressions.html
- name: Check for changes
id: status
run: |
source ../.github/workflows/actions.sh
if [ -n "$(git status --porcelain)" ]; then
set_output has_changes 1
fi
working-directory: gh-pages
- name: Publish documentation
run: |
git add --verbose .
git config user.name 'Edward Thomson'
git config user.email '[email protected]'
git commit -m 'Documentation update'
git push origin gh-pages
if: steps.status.outputs.has_changes == '1'
working-directory: gh-pages