111 lines
4.1 KiB
YAML
111 lines
4.1 KiB
YAML
name: Deploy Jekyll site to Pages
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
# Runs every 3 hours to update pack and game version
|
|
schedule:
|
|
- cron: '0 */12 * * *'
|
|
|
|
# Allows you to run this workflow manually from the Actions tab
|
|
workflow_dispatch:
|
|
|
|
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
concurrency:
|
|
group: "pages"
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-22.04
|
|
env:
|
|
RUBY_VERSION: "3.3.5"
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
- name: Install Dependencies
|
|
run: |
|
|
sudo apt-get update
|
|
sudo apt-get install -y jq curl sed imagemagick wget tar build-essential zlib1g-dev gpg libmagickwand-dev webp
|
|
which cwebp
|
|
- name: Fetch Latest Modrinth Version
|
|
id: fetch_version
|
|
run: |
|
|
# Modrinth API Call
|
|
response=$(curl -s -H "Authorization: Bearer $MODRINTH_TOKEN" https://api.modrinth.com/v2/project/illuvia-prime-project/version)
|
|
|
|
# Extract latest release version
|
|
latest_release=$(echo "$response" | jq -cr '[.[] | select(.status == "listed" and .version_type == "release")] | sort_by(.date_published) | last')
|
|
|
|
if [ -z "$latest_release" ]; then
|
|
echo "No release version found"
|
|
exit 1
|
|
fi
|
|
|
|
# Extract version_number and game_versions
|
|
version_number=$(echo "$latest_release" | jq -r '.version_number')
|
|
game_version=$(echo "$latest_release" | jq -r '.game_versions[0]')
|
|
current_date=$(date +"%d.%m.%Y %H:%m")
|
|
|
|
echo "Latest version: $version_number (Minecraft $game_version) on $current_date"
|
|
|
|
# Output for next steps
|
|
echo "PACK_VERSION=$version_number" >> $GITHUB_ENV
|
|
echo "MINECRAFT_VERSION=$game_version" >> $GITHUB_ENV
|
|
echo "CURRENT_DATE=$current_date" >> $GITHUB_ENV
|
|
- name: Update _config.yml
|
|
run: |
|
|
# Replace placeholders
|
|
sed -i "s/PACK_VERSION/$PACK_VERSION/g" _config.yml
|
|
sed -i "s/MINECRAFT_VERSION/$MINECRAFT_VERSION/g" _config.yml
|
|
sed -i "s/PACK_VERSION/$PACK_VERSION/g" assets/launcher_motd.txt
|
|
sed -i "s/CURRENT_DATE/$CURRENT_DATE/g" assets/launcher_motd.txt
|
|
- name: Convert images to WebP
|
|
run: |
|
|
DIRECTORY=assets/img
|
|
OUTPUT_DIRECTORY=assets/img
|
|
mkdir -p $OUTPUT_DIRECTORY
|
|
|
|
for file in $DIRECTORY/*.{jpg,jpeg,png}; do
|
|
if [ -f "$file" ]; then
|
|
filename=$(basename -- "$file")
|
|
name="${filename%.*}"
|
|
cwebp "$file" -o "$OUTPUT_DIRECTORY/$name.webp"
|
|
fi
|
|
done
|
|
- name: checkout pages
|
|
uses: actions/checkout@v4
|
|
with:
|
|
ref: "pages"
|
|
path: "pages"
|
|
- name: Setup Ruby
|
|
run: |
|
|
apt-get update
|
|
apt-get install curl wget tar build-essential zlib1g-dev gpg -y
|
|
curl -sSL https://rvm.io/mpapis.asc | gpg --import -
|
|
curl -sSL https://rvm.io/pkuczynski.asc | gpg --import -
|
|
curl -sSL https://get.rvm.io | bash -s stable
|
|
source /etc/profile.d/rvm.sh
|
|
rvm mount -r https://git.morlana.online/api/packages/Morlana/generic/ruby-ubuntu-22.04-aarch64/$RUBY_VERSION/ruby-$RUBY_VERSION.tar.bz2
|
|
rvm use $RUBY_VERSION && ruby -v && gem -v
|
|
gem install bundler jekyll webrick
|
|
- name: Build with Jekyll
|
|
run: |
|
|
source /etc/profile.d/rvm.sh
|
|
rvm use $RUBY_VERSION && ruby -v && gem -v
|
|
bundle install
|
|
bundle exec jekyll build --destination pages
|
|
env:
|
|
JEKYLL_ENV: production
|
|
- name: push pages
|
|
run: |
|
|
cd pages
|
|
cp ../.domains ./.domains
|
|
git config user.name "${{ gitea.actor }}"
|
|
git config user.email ""${{ gitea.actor }}"@noreply.git.morlana.online"
|
|
git add -A
|
|
git commit -m "jekyll build from Action ${GITHUB_SHA}"
|
|
git push
|