-
Notifications
You must be signed in to change notification settings - Fork 15
135 lines (126 loc) · 4.17 KB
/
deploy-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
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
name: Deploy Pages
on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: "* */1 * * *" # every one hour
permissions:
contents: read
pages: write
id-token: write
concurrency:
group: "pages"
cancel-in-progress: true
defaults:
run:
shell: bash
jobs:
# Pulls the output.json from the latest successful run of the gateway-conformance.yml workflow
# and stores these as an artifacts for the build job.
pull-outputs:
runs-on: "ubuntu-latest"
strategy:
matrix:
target: ["ipfs/kubo", "ipfs/boxo", "ipfs/bifrost-gateway"]
fail-fast: false
defaults:
run:
shell: bash
steps:
- name: get repo details
id: get-details
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
OWNER_AND_REPO: ${{ matrix.target }}
run: |
DETAILS=$(gh api repos/${OWNER_AND_REPO})
DEFAULT_BRANCH=$(echo $DETAILS | jq -r '.default_branch')
echo "default-branch=${DEFAULT_BRANCH}" >> $GITHUB_OUTPUT
NAME=$(echo $DETAILS | jq -r '.name')
echo "name=${NAME}" >> $GITHUB_OUTPUT
- name: Download json output
id: download-artifact
uses: dawidd6/action-download-artifact@v2 # TODO: pin
with:
workflow: gateway-conformance.yml
workflow_conclusion: "completed" # TODO: ideally we could request success|failure (https://github.com/dawidd6/action-download-artifact#usage)
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ steps.get-details.outputs.default-branch }}
name: gateway-conformance.json
repo: ${{ matrix.target }}
if_no_artifact_found: fail
- name: Upload JSON output
if: (failure() || success())
uses: actions/upload-artifact@v3
with:
name: conformance-${{ steps.get-details.outputs.name }}.json
path: ./output.json
# https://github.com/actions/starter-workflows/blob/4a8f18e34dd13d2b6ee4d8da2ba72629eafe1609/pages/hugo.yml#L1
build:
runs-on: ubuntu-latest
env:
HUGO_VERSION: 0.117.0
needs: [pull-outputs]
steps:
- name: Setup Hugo
uses: peaceiris/actions-hugo@16361eb4acea8698b220b76c0d4e84e1fd22c61d # v2.6.0
with:
hugo-version: ${{ env.HUGO_VERSION }}
extended: true
- name: Checkout
uses: actions/checkout@v3
- name: Setup Pages
id: pages
uses: actions/configure-pages@v1
- name: Download Artifacts
uses: actions/download-artifact@v3
with:
path: artifacts
- name: Generate Data Aggregates
working-directory: ./
run: |
npm ci
mkdir ./munged
# download-artifact downloads artifacts in a directory named after the artifact
# details: https://github.com/actions/download-artifact#download-all-artifacts
for folder in ./artifacts/conformance-*.json; do
file="${folder}/output.json"
new_file="./munged/${folder#.\/artifacts\/conformance-}" # drop the ./artifacts/conformance- prefix
cat "$file" | node ./munge.js > "${new_file}"
done
# generate the sqlite database from our munged files
node ./munge_sql.js ./aggregates.db ./munged/*.json
- name: Upload Data Aggregates
# will be very useful for local debugging
if: (failure() || success())
uses: actions/upload-artifact@v3
with:
name: dashboard-aggregates
path: |
./munged
./aggregates.db
- name: Generate Content
run: |
node ./munge_aggregates.js ./aggregates.db ./www
- name: Build with Hugo
run: |
hugo \
--minify \
--baseURL ${{ steps.pages.outputs.base_url }}
working-directory: www
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./www/public
deploy:
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
needs: build
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v1