forked from obhq/obhq.github.io
-
Notifications
You must be signed in to change notification settings - Fork 0
103 lines (86 loc) · 3.61 KB
/
compatibility.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
# Automatically update the database when an issue in the compatibility repo gets updated
name: Compatibility List Updater
on:
issues:
types:
- labeled
- edited
- closed
- deleted
repositories:
- obhq/compatibility
workflow_dispatch:
inputs:
manual:
description: Manually updates the database!
env:
CARGO_TERM_COLOR: always
GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }}
HOMEBREW_API_TOKEN: ${{ secrets.HOMEBREW_API_TOKEN }}
TMDB_HEX: ${{ secrets.TMDB_HEX }}
defaults:
run:
working-directory: updater/
jobs:
build:
name: obhqWebsite_database_updater
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v4
- name: setup rust
run: |
rustup update stable
rustup default stable
- name: restore old images && database
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git fetch origin gh-pages
git switch gh-pages --force
mkdir -p /home/runner/work/obhqWebsite/temp/updater/images/
# if there are images, copy em over
if [ -d /home/runner/work/obhqWebsite/obhqWebsite/public_html/Gamma-Boi/compatibility/_images/ ]; then
echo "Copying Images"
cp -r /home/runner/work/obhqWebsite/obhqWebsite/compatibility/_images/ /home/runner/work/obhqWebsite/temp/updater/images/
fi
# if there is an old main db, copy it over
if [ -f /home/runner/work/obhqWebsite/obhqWebsite/compatibility/database.json]; then
echo "Copying Old Database"
cp -r /home/runner/work/obhqWebsite/obhqWebsite/compatibility/database.json /home/runner/work/obhqWebsite/temp/updater/database.json
fi
git fetch origin main
git switch main --force
- name: run obhqWebsite_database_updater
run: cargo run --release
- name: Commit and push changes to main
run: |
git add game_skips.json -f
git add HBstore.db -f
git add config/config.toml -f
files_to_commit=$(git status --porcelain | grep -E 'M|A|D' | wc -l)
if [ $files_to_commit -gt 0 ]; then
echo "Committing changes!"
git commit -m "Compatibility List database Update"
git push origin main
else
echo "No changes to commit."
fi
- name: Commit and push changes to gh-pages
run: |
git fetch origin gh-pages
git switch gh-pages --force
mv /home/runner/work/obhqWebsite/temp/updater/images/* /home/runner/work/obhqWebsite/obhqWebsite/compatibility/_images/
mv /home/runner/work/obhqWebsite/temp/updater/database.json /home/runner/work/obhqWebsite/obhqWebsite/compatibility/database.json
mv /home/runner/work/obhqWebsite/temp/updater/stats.json /home/runner/work/obhqWebsite/obhqWebsite/stats.json
git add /home/runner/work/obhqWebsite/obhqWebsite/stats.json -f
git add /home/runner/work/obhqWebsite/obhqWebsite/compatibility/database.json -f
git add /home/runner/work/obhqWebsite/obhqWebsite/compatibility/_images/ -f
files_to_commit=$(git status --porcelain | grep -E 'M|A|D' | wc -l)
if [ $files_to_commit -gt 0 ]; then
echo "Committing changes!"
git commit -m "Compatibility List Update"
git push origin gh-pages
else
echo "No changes to commit."
fi