-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (89 loc) · 2.89 KB
/
deploy-scan-results-to-github-pages.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
name: Deploy-scan-results-to-GitHub-pages
on:
push:
branches:
- main
permissions:
contents: write
env:
DAY_OF_WEEK: $(date +%Y%m%d%H%M%S)
jobs:
build-and-deploy:
concurrency: ci-${{ github.ref }} # Recommended if you intend to make multiple deployments in quick succession.
runs-on: ubuntu-latest
env:
Greeting: $(date +%s)
steps:
- name: Set the time
run: |
echo "ACTION_START_TIME=$(date +%s)" >> $GITHUB_OUTPUT
id: run_tests
- name: Checkout 🛎️
uses: actions/checkout@v3
- name: Creating scan results
run: |
reportName='scan-results/result-${{steps.run_tests.outputs.ACTION_START_TIME}}.json'
cat
{
echo ''
echo "<script>"
echo "const resultJson = "
echo "</script>"
echo "<script>"
echo "const createdAt = $(date +%s);"
echo "init();"
echo "</script>"
echo "</body>"
echo "</html>"
} >>"$reportName"
echo "$reportName has been created!"
- name: Creating Scan Details
run: |
scan_index='scan-results/scan_index.json'
echo "DAY_OF_WEEK: $DAY_OF_WEEK"
echo "Greeting: $Greeting"
cat
{
echo '{'
echo '"Id": "${{steps.run_tests.outputs.ACTION_START_TIME}}"'
echo '"Sha": "${{ github.sha }}"'
echo '"Initiator": "${{ github.triggering_actor }}"'
echo '"Ref": "${{ github.ref }}"'
echo '"Event_Name": "${{ github.event_name }}"'
echo '"Event_Path": "${{ github.event_path }}"'
echo '},'
} >>"$scan_index"
echo "$scan_index has been created!"
- name: Checkout gh 🛎️
uses: actions/checkout@v3
with:
ref: gh-pages
path: gh-pages
- name: Adding Scan Details to Audit db
run: |
audit_file='gh-pages/index.json'
scan_index='scan-results/scan_index.json'
if [ ! -f $audit_file ]; then
echo "$audit_file doesn't exist, creating an empty one!"
cat
{
echo '{'
echo '"Pushes" : ['
echo ']}'
} >>"$audit_file"
fi
index='scan-results/index.json'
head -n -1 "$audit_file" > "$index"
#cat "$audit_file" >>"$index"
cat "$scan_index" >>"$index"
cat
{
echo ''
echo ']}'
} >>"$index"
echo "$index has been created!"
rm -f $scan_index
- name: Deploy 🚀
uses: JamesIves/github-pages-deploy-action@v4
with:
folder: scan-results