-
Notifications
You must be signed in to change notification settings - Fork 0
52 lines (44 loc) · 1.42 KB
/
update-index.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
name: Update index
on:
push:
branches:
- main
workflow_dispatch:
jobs:
update-index:
if: github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
path: main
- uses: actions/checkout@v4
with:
ref: 'gh-pages'
path: 'gh-pages'
token: ${{ secrets.PAT }}
- name: Update static index
env:
REGISTRY_AUTH_FILE: /tmp/auth.json
run: |
export FILES="./main/repos/*"
echo '{"Registry": "https://ghcr.io/","Results": []}' > ./gh-pages/index/static
for f in $FILES ; do
echo "Processing $f file..."
cat ./gh-pages/index/static | jq --argjson container "$(cat $f)" '.Results += [ $container ]' > ./gh-pages/index/static
done
- name: Check for changes
id: is-updated
run: |
set -x
git -C ./gh-pages status -s -uno
cat ./gh-pages/index/static
# Don't let the file be empty
[ ! -s ./gh-pages/index/static ] || [ -z "$(git -C ./gh-pages status -s -uno)" ] || echo "updated=true" >> $GITHUB_OUTPUT
- name: Push to repository
if: steps.is-updated.outputs.updated
run: |
git config --global user.name 'github-actions[bot]'
git config --global user.email 'github-actions[bot]@users.noreply.github.com'
git -C gh-pages commit -am "Update index"
git -C gh-pages push