website/.forgejo/workflows/generate.yml

77 lines
2.2 KiB
YAML
Raw Normal View History

2024-12-14 04:06:26 +00:00
name: Generate Website
on:
workflow_dispatch:
push:
branches:
- master
env:
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
2024-12-14 09:10:54 +00:00
run: apk add --no-cache nodejs git git-lfs bash curl zstd
2024-12-14 04:06:26 +00:00
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
2024-12-17 04:33:23 +00:00
- name: Checkout assets
2024-12-14 04:06:26 +00:00
uses: actions/checkout@v4
with:
token: ${{ secrets.TOKEN }}
repository: sapphirus.org/Suo
sparse-checkout: |
templates/assets
dist
lfs: true
show-progress: true
path: suo
2024-12-14 10:11:58 +00:00
- name: Fetch suo binary
2024-12-14 04:06:26 +00:00
shell: bash
run: |
POST_URL=https://git.sapphirus.org/api/packages/private/generic/suo/latest/suo
2024-12-14 10:11:58 +00:00
echo "::group:: Fetching suo"
mkdir ./bin/ && curl --user $USER_NAME:$USER_TOKEN $POST_URL --output ./bin/suo && chmod +x ./bin/suo
2024-12-14 04:06:26 +00:00
echo "::endgroup::"
- name: Generate website
2024-12-14 10:11:58 +00:00
run: ./bin/suo && ./suo/dist/assets.sh ./output ./suo
2024-12-14 04:06:26 +00:00
- name: Package website
shell: bash
run: |
echo "::group:: Packaging website"
2024-12-14 10:11:58 +00:00
cd output
2024-12-14 04:06:26 +00: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: |
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