Skip to content

Commit

Permalink
Added .yml files and changed folder structure
Browse files Browse the repository at this point in the history
I hate github actions...
  • Loading branch information
MrSn0wy committed Jun 28, 2024
1 parent 7f8e746 commit b13c869
Show file tree
Hide file tree
Showing 25 changed files with 804 additions and 843 deletions.
113 changes: 113 additions & 0 deletions .github/workflows/compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,113 @@
# Automatically update the database when an issue in the compatibility repo gets updated

name: Compatibility List Updater
on:
issues:
types:
- opened
- 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/compatibility/_images/ ]; then
echo "Copying Images"
cp -a -r -f /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 -a -r -f /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 fetch origin main
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 fetch origin main
git commit -m "Automatic Compatibility List 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
mkdir -p /home/runner/work/obhqWebsite/obhqWebsite/compatibility/_images/
rm -r -f /home/runner/work/obhqWebsite/obhqWebsite/compatibility/_images/games/
rm -r -f /home/runner/work/obhqWebsite/obhqWebsite/compatibility/_images/hb/
rm -f /home/runner/work/obhqWebsite/obhqWebsite/compatibility/database.json
rm -f /home/runner/work/obhqWebsite/obhqWebsite/stats.json
mv -f /home/runner/work/obhqWebsite/temp/updater/images/* /home/runner/work/obhqWebsite/obhqWebsite/compatibility/_images/
mv -f /home/runner/work/obhqWebsite/temp/updater/database.json /home/runner/work/obhqWebsite/obhqWebsite/compatibility/database.json
mv -f /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 fetch origin gh-pages
git commit -m "Automatic Compatibility List Update"
git push origin gh-pages
else
echo "No changes to commit."
fi
57 changes: 57 additions & 0 deletions .github/workflows/mdbook.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Automatically updates the mdbook on build

name: mdbook updater
on:
push:
branches:
- main
paths:
- mdbook/**
workflow_dispatch:
inputs:
manual:
description: Manually updates the mdbook!

defaults:
run:
working-directory: mdbook/

jobs:
build:
name: mdbook updater
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v4

- name: setup rust
run: |
rustup update stable
rustup default stable
- name: install mdbook
run: cargo install mdbook

- name: build mdbook
run: |
mdbook build --dest-dir /home/runner/work/obhqWebsite/temp/wiki/
- name: Commit and push changes to gh-pages
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
rm -r -f /home/runner/work/obhqWebsite/obhqWebsite/wiki/
mv -f /home/runner/work/obhqWebsite/temp/wiki/ /home/runner/work/obhqWebsite/obhqWebsite/wiki/
git add /home/runner/work/obhqWebsite/obhqWebsite/wiki/
files_to_commit=$(git status --porcelain | grep -E 'M|A|D' | wc -l)
if [ $files_to_commit -gt 0 ]; then
echo "Committing changes!"
git fetch origin gh-pages
git commit -m "Automatic mdbook Update"
git push origin gh-pages
else
echo "No changes to commit."
fi
55 changes: 55 additions & 0 deletions .github/workflows/public_html.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: public_html update
on:
push:
branches:
- main
paths:
- public_html/**
workflow_dispatch:
inputs:
manual:
description: Manually updates the public_html!

jobs:
build:
name: public_html Updater
runs-on: ubuntu-latest
steps:
- name: checkout repository
uses: actions/checkout@v4

- name: Copy files
run: |
mkdir -p /home/runner/work/obhqWebsite/temp/public_html/
cp -a -r -f /home/runner/work/obhqWebsite/obhqWebsite/public_html/* /home/runner/work/obhqWebsite/temp/public_html/
- name: Commit and push changes to gh-pages
run: |
# Switch to gh-pages
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
# put the new files into the folder
rm -r -f /home/runner/work/obhqWebsite/obhqWebsite/*
mv -f /home/runner/work/obhqWebsite/temp/public_html/* /home/runner/work/obhqWebsite/obhqWebsite/
touch /home/runner/work/obhqWebsite/obhqWebsite/.nojekyll
git add /home/runner/work/obhqWebsite/obhqWebsite/ -f
# restore files that dont need updating
git restore --staged --worktree wiki/
git restore --staged --worktree compatibility/_images/games/
git restore --staged --worktree compatibility/_images/hb/
git restore --staged --worktree compatibility/database.json
git restore --staged --worktree stats.json
files_to_commit=$(git status --porcelain | grep -E 'M|A|D' | wc -l)
if [ $files_to_commit -gt 0 ]; then
echo "Committing changes!"
git fetch origin gh-pages
git commit -m "Automatic public_html update"
git push origin gh-pages
else
echo "No changes to commit."
fi
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@ stuff.txt
*.db
.htaccess

mdbook/book/
updater/images/
updater/config/config.toml
/public_html/Gamma-Boi/compatibility/_images/games/
/public_html/Gamma-Boi/compatibility/_images/hb/

Expand Down
21 changes: 19 additions & 2 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,24 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

### [v0.2.0] (unreleased)
### [v0.3.0] (unreleased)

#### Added

- .yml files for automatic releases
- Modified rust comp updater to get the secrets using the environmental variables

#### Changed

- Changed directories of the website
- Aesthetic changes and error handling improvements to the rust comp updater

#### Removed

- Removed Coming soon page
- Removed `Gamma-Boi`

### [v0.2.0]

#### Added

Expand Down Expand Up @@ -39,7 +56,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Updated the config
- Fixed direction of issues being flipped

### [v0.1.0] (unreleased)
### [v0.1.0]

#### Added

Expand Down
1 change: 0 additions & 1 deletion mdbook/.gitignore

This file was deleted.

4 changes: 2 additions & 2 deletions mdbook/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,5 @@ src = "src"
edition = "2018"

[build]
build-dir = 'D:\Website\public_html\Gamma-Boi\wiki'
create-missing = false
build-dir = '/home/runner/work/obhqWebsite/temp/wiki/'
create-missing = true
1 change: 1 addition & 0 deletions public_html/.nojekyll
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Prevents Github Pages from being silly
53 changes: 0 additions & 53 deletions public_html/Gamma-Boi/app.js

This file was deleted.

Loading

0 comments on commit b13c869

Please sign in to comment.