2024-12-13 23:06:26 -05:00
|
|
|
name: Generate Website
|
|
|
|
|
|
|
|
on:
|
2024-12-23 00:53:09 -05:00
|
|
|
schedule:
|
|
|
|
- cron: '0 0 1 1 *'
|
2024-12-13 23:06:26 -05:00
|
|
|
workflow_dispatch:
|
|
|
|
push:
|
|
|
|
branches:
|
|
|
|
- master
|
|
|
|
|
|
|
|
env:
|
|
|
|
USER_TOKEN: ${{ secrets.TOKEN }}
|
|
|
|
USER_NAME: ${{ vars.USER }}
|
|
|
|
|
|
|
|
jobs:
|
2024-12-23 00:53:09 -05:00
|
|
|
generate:
|
2024-12-13 23:06:26 -05:00
|
|
|
name: Generate Website
|
|
|
|
runs-on: docker
|
|
|
|
container:
|
|
|
|
image: alpine
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
toolchain:
|
|
|
|
- stable
|
|
|
|
steps:
|
|
|
|
- name: Install packages
|
2024-12-14 04:10:54 -05:00
|
|
|
run: apk add --no-cache nodejs git git-lfs bash curl zstd
|
2024-12-13 23:06:26 -05:00
|
|
|
- name: Checkout repository
|
|
|
|
uses: actions/checkout@v4
|
2024-12-16 00:45:08 -05:00
|
|
|
with:
|
|
|
|
fetch-depth: 0
|
2024-12-16 23:33:23 -05:00
|
|
|
- name: Checkout assets
|
2024-12-13 23:06:26 -05:00
|
|
|
uses: actions/checkout@v4
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.TOKEN }}
|
|
|
|
repository: sapphirus.org/Suo
|
|
|
|
sparse-checkout: |
|
|
|
|
templates/assets
|
|
|
|
dist
|
|
|
|
path: suo
|
2024-12-17 01:31:30 -05:00
|
|
|
- name: Pull from LFS
|
|
|
|
run: |
|
|
|
|
# Double authentication header workaround for actions/checkout@v4
|
|
|
|
# https://github.com/actions/checkout/issues/1830#issuecomment-2314758792
|
|
|
|
AUTH=$(git -C suo config --local http.$SERVER/.extraheader)
|
|
|
|
git -C suo config --local --unset http.$SERVER/.extraheader
|
|
|
|
git -C suo config --local http.$SERVER/$REPOSITORY/info/lfs/objects/batch.extraheader "$AUTH"
|
|
|
|
git -C suo lfs pull
|
|
|
|
env:
|
|
|
|
SERVER: ${{ github.server_url }}
|
|
|
|
REPOSITORY: sapphirus.org/Suo
|
2024-12-14 05:11:58 -05:00
|
|
|
- name: Fetch suo binary
|
2024-12-13 23:06:26 -05:00
|
|
|
shell: bash
|
|
|
|
run: |
|
2024-12-20 20:39:10 -05:00
|
|
|
POST_URL="https://git.sapphirus.org/api/packages/private/generic/suo/latest/suo"
|
2024-12-13 23:06:26 -05:00
|
|
|
|
2024-12-14 05:11:58 -05:00
|
|
|
echo "::group:: Fetching suo"
|
2024-12-20 20:39:10 -05:00
|
|
|
mkdir ./bin/ &&
|
|
|
|
curl --silent \
|
|
|
|
--show-error \
|
|
|
|
--user $USER_NAME:$USER_TOKEN $POST_URL \
|
|
|
|
--output ./bin/suo &&
|
|
|
|
chmod +x ./bin/suo
|
|
|
|
echo "::endgroup::"
|
2024-12-13 23:06:26 -05:00
|
|
|
- name: Generate website
|
2024-12-14 05:11:58 -05:00
|
|
|
run: ./bin/suo && ./suo/dist/assets.sh ./output ./suo
|
2024-12-13 23:06:26 -05:00
|
|
|
- name: Package website
|
|
|
|
shell: bash
|
|
|
|
run: |
|
|
|
|
echo "::group:: Packaging website"
|
2024-12-14 05:11:58 -05:00
|
|
|
cd output
|
2024-12-13 23:06:26 -05:00
|
|
|
tar acvf website.tar.zst *
|
|
|
|
echo "$(git rev-parse --short HEAD)$(git -C ../suo rev-parse --short HEAD)" > website.ver
|
|
|
|
echo "::endgroup::"
|
|
|
|
- name: Upload package
|
|
|
|
shell: bash
|
|
|
|
run: |
|
2024-12-20 20:39:10 -05:00
|
|
|
POST_URL="https://git.sapphirus.org/api/packages/private/generic/website/latest/"
|
2024-12-13 23:06:26 -05:00
|
|
|
SRC_DIR="./output/"
|
2024-12-20 20:39:10 -05:00
|
|
|
FILES=$(ls "$SRC_DIR"*.tar.zst "$SRC_DIR"*.ver)
|
2024-12-13 23:06:26 -05:00
|
|
|
|
|
|
|
for file in $FILES; do
|
|
|
|
echo "::group:: Removing $file"
|
2024-12-20 20:39:10 -05:00
|
|
|
curl --silent \
|
|
|
|
--show-error \
|
|
|
|
--user $USER_NAME:$USER_TOKEN \
|
|
|
|
-X DELETE $POST_URL${file##$SRC_DIR}
|
|
|
|
echo "::endgroup::"
|
2024-12-13 23:06:26 -05:00
|
|
|
done
|
|
|
|
|
|
|
|
for file in $FILES; do
|
|
|
|
echo "::group:: Publishing $file"
|
2024-12-20 20:39:10 -05:00
|
|
|
curl --silent \
|
|
|
|
--show-error \
|
|
|
|
--user $USER_NAME:$USER_TOKEN \
|
|
|
|
--upload-file $file $POST_URL${file##$SRC_DIR}
|
|
|
|
echo "::endgroup::"
|
2024-12-13 23:06:26 -05:00
|
|
|
done
|