-
Notifications
You must be signed in to change notification settings - Fork 7
149 lines (120 loc) · 4.06 KB
/
indexer.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
name: indexer
# we have to generate an index for each pkg so that the index.html that is
# served has the correct metadata
#TODO a lambda would be better because we copy the index.html from the bucket
# root and modify it then push that back so it could easily get out of sync
on:
workflow_call:
workflow_dispatch:
schedule:
- cron: "13 * * * *"
pull_request:
branches: main
paths:
- .github/scripts/*.ts
- .github/workflows/indexer.yml
push:
branches: main
paths:
- .github/scripts/*.ts
- .github/workflows/indexer.yml
concurrency:
group: indexer
cancel-in-progress: true
jobs:
indexer:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: pkgxdev/pantry
path: pantry
fetch-depth: 0 # needed to get git metadata for ordering purposes
- uses: pkgxdev/setup@v3
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.WWW_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.WWW_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- uses: actions/checkout@v4
with:
ref: gh-pages
path: public/pkgs
- run: aws s3 cp s3://www.pkgx.dev/index.html ./public/index.html
- run: ../.github/scripts/gen-pkgs-index.json.ts > ../public/pkgs/index.json
working-directory: pantry
- run: .github/scripts/gen-index.html.ts
- run: aws s3 sync
public/pkgs/ s3://www.pkgx.dev/pkgs/
--metadata-directive REPLACE
--cache-control no-cache,must-revalidate
- run: aws cloudfront
create-invalidation
--distribution-id E15VQ3SI584CSG
--paths /pkgs /pkgs/ /pkgs/*
- uses: actions/upload-artifact@v4
with:
name: pkg-index
path: public/pkgs/index.json
root-indexer:
needs: indexer
runs-on: ubuntu-latest
steps:
- uses: pkgxdev/setup@v3
- uses: actions/checkout@v4
- uses: actions/checkout@v4
with:
repository: pkgxdev/pantry
path: pantry
- uses: actions/download-artifact@v4
with:
name: pkg-index
- run: curl https://pkgxdev.github.io/mash/index.json > scripthub.json
- run: |
.github/scripts/gen-feed.ts \
--blog-path ./blog \
--pkgs-json ./index.json \
--scripthub-json ./scripthub.json \
--pantry-path ./pantry \
> out_index.json
- uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.WWW_AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.WWW_AWS_SECRET_ACCESS_KEY }}
aws-region: us-east-2
- run: aws s3 cp out_index.json s3://www.pkgx.dev/index.json
- run: aws cloudfront
create-invalidation
--distribution-id E15VQ3SI584CSG
--paths /index.json
algolia:
needs: indexer
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
repository: pkgxdev/pantry
fetch-depth: 0 # needed to get git metadata for ordering purposes
- uses: actions/checkout@v4
with:
path: utils
- uses: actions/download-artifact@v4
with:
name: pkg-index
- uses: pkgxdev/setup@v3
- run: utils/.github/scripts/gen-algolia-data.ts > algolia.json
- name: Upload JSON file to Algolia
env:
ALGOLIA_APP_ID: UUTLHX01W7
JSON_FILE: ./algolia.json
run: |
curl \
--fail \
--request POST \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header "X-Algolia-Application-Id: $ALGOLIA_APP_ID" \
--header "X-Algolia-API-Key: ${{ secrets.ALGOLIA_ADMIN_KEY }}" \
--data-binary "@$JSON_FILE" \
"https://${ALGOLIA_APP_ID}.algolia.net/1/indexes/pkgs/batch"