82 lines
2.4 KiB
YAML
82 lines
2.4 KiB
YAML
|
name: Generate Website
|
||
|
|
||
|
on:
|
||
|
workflow_dispatch:
|
||
|
push:
|
||
|
branches:
|
||
|
- master
|
||
|
|
||
|
env:
|
||
|
CARGO_TERM_COLOR: always
|
||
|
PATH: /usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/root/.cargo/bin
|
||
|
RUSTFLAGS: -C target-feature=-crt-static
|
||
|
USER_TOKEN: ${{ secrets.TOKEN }}
|
||
|
USER_NAME: ${{ vars.USER }}
|
||
|
|
||
|
jobs:
|
||
|
build:
|
||
|
name: Generate Website
|
||
|
runs-on: docker
|
||
|
container:
|
||
|
image: alpine
|
||
|
strategy:
|
||
|
matrix:
|
||
|
toolchain:
|
||
|
- stable
|
||
|
steps:
|
||
|
- name: Install packages
|
||
|
run: apk add --no-cache rustup nodejs git git-lfs build-base pkgconfig bash curl zstd
|
||
|
- name: Checkout repository
|
||
|
uses: actions/checkout@v4
|
||
|
- name: Checkout repository (suo)
|
||
|
uses: actions/checkout@v4
|
||
|
with:
|
||
|
token: ${{ secrets.TOKEN }}
|
||
|
repository: sapphirus.org/Suo
|
||
|
sparse-checkout: |
|
||
|
templates/assets
|
||
|
dist
|
||
|
lfs: true
|
||
|
show-progress: true
|
||
|
path: suo
|
||
|
- name: Fetch suo
|
||
|
shell: bash
|
||
|
run: |
|
||
|
POST_URL=https://git.sapphirus.org/api/packages/private/generic/suo/latest/suo
|
||
|
|
||
|
echo "::group:: Fetching suo"
|
||
|
cd suo
|
||
|
curl --user $USER_NAME:$USER_TOKEN $POST_URL${file##$SRC_DIR} --output suo && chmod +x suo
|
||
|
echo "::endgroup::"
|
||
|
- name: Generate website
|
||
|
shell: bash
|
||
|
run: |
|
||
|
cd suo
|
||
|
./suo ../input/ ../output && ./dist/assets.sh ../output
|
||
|
- name: Package website
|
||
|
shell: bash
|
||
|
run: |
|
||
|
cd output
|
||
|
echo "::group:: Packaging website"
|
||
|
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: |
|
||
|
POST_URL=https://git.sapphirus.org/api/packages/private/generic/website/latest/
|
||
|
SRC_DIR="./output/"
|
||
|
FILES=$(ls $SRC_DIR*.tar.zst $SRC_DIR*.ver)
|
||
|
|
||
|
for file in $FILES; do
|
||
|
echo "::group:: Removing $file"
|
||
|
curl --user $USER_NAME:$USER_TOKEN -X DELETE $POST_URL${file##$SRC_DIR}
|
||
|
echo -e "\n::endgroup::"
|
||
|
done
|
||
|
|
||
|
for file in $FILES; do
|
||
|
echo "::group:: Publishing $file"
|
||
|
curl --user $USER_NAME:$USER_TOKEN --upload-file $file $POST_URL${file##$SRC_DIR}
|
||
|
echo -e "\n::endgroup::"
|
||
|
done
|