-
Notifications
You must be signed in to change notification settings - Fork 1
/
action.yml
133 lines (105 loc) · 3.63 KB
/
action.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
name: 'Flexion Tech Radar Generator'
description: 'Generates a tech radar based on the provided folder. Initially based in the AOE radar'
author: David Vega <[email protected]>
#TODO: Add parameter for input format for the radar;
# Markdown is implied, under the AOE radar format "<version>/*.md",
# but JSON is also supported
#TODO: Parametrize radar engine; AOE Radar is implied
inputs:
directory:
description: 'Folder containing the tech radar data within the repository'
required: true
artifact_name:
description: 'Name of the artifact to upload (optional)'
required: false
publish_to_pages:
description: 'Publish to GitHub Pages (optional)'
required: false
default: "false"
base_path:
description: 'Base path used to resolve assets after the domain, e.g. "/techradar"'
required: false
default: "/"
base_dir:
description: |
Base directory to build within export directory, can differ from
base path for GH Pages where the pages URL inclues repository name
as first segment
required: false
default: "/"
radar_name:
description: 'Name of the radar (optional)'
required: false
default: "Flexion Tech Radar"
outputs:
pages_url:
description: 'URL of the GitHub Pages deployment'
value: ${{ steps.deployment.outputs.page_url }}
runs:
using: "composite"
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup node
uses: actions/setup-node@v4
with:
node-version: 20
#TODO: Parametrize radar version
#TODO: Extract to script
- name: Install AOE radar & build static assets
shell: bash
working-directory: ${{ inputs.directory }}
run: |
export REACT_APP_RADAR_NAME="${{ inputs.radar_name }}"
sudo apt-get update
sudo apt-get install moreutils
pwd
ls -al
# If no package.json is present, copy the one from this action
if [ ! -f package.json ]; then
cp -r $GITHUB_ACTION_PATH/package.json .
fi
cat package.json
#If no config.json is present, create one with an empty object
if [ ! -f config.json ]; then
echo "{}" > config.json
fi
# Use jq to create/overwrite in-place the basePath in the config.json
jq \
--arg base_path "${{ inputs.base_path }}" \
--arg radar_name "${{ inputs.radar_name }}" \
'.basePath = $base_path
|
.labels.title = $radar_name' \
config.json \
| sponge config.json
cat config.json
# Install dependencies and build the radar
npm install
ls node_modules/.bin # Debug: list the contents of node_modules/.bin
npm run build
export EXPORT_DIR=export/${{ inputs.base_dir }}
mkdir -p $EXPORT_DIR
cp -r build/* $EXPORT_DIR
chmod -R 755 $EXPORT_DIR
- name: Upload artifact
if: ${{ inputs.publish_to_pages == 'false' }}
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact_name || 'tech-radar' }}
path: "${{ inputs.directory }}/export"
- name: Setup Pages
if: ${{ inputs.publish_to_pages == 'true' }}
uses: actions/configure-pages@v5
# with:
# static_site_generator: next
- name: Upload artifact to Pages
if: ${{ inputs.publish_to_pages == 'true' }}
uses: actions/upload-pages-artifact@v3
with:
path: ${{ inputs.directory }}/export
#TODO: Add more deployment targets
- name: Deploy to GitHub Pages
if: ${{ inputs.publish_to_pages == 'true' }}
id: deployment
uses: actions/deploy-pages@v4