Data #14
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# Copyright (C) 2023 AuxXxilium <https://github.com/AuxXxilium> and Ing <https://github.com/wjz304> | |
# | |
# This is free software, licensed under the MIT License. | |
# See /LICENSE for more information. | |
# | |
name: Data | |
on: | |
release: | |
types: | |
- created | |
workflow_dispatch: | |
inputs: | |
push: | |
description: "push" | |
default: false | |
type: boolean | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@main | |
with: | |
ref: page | |
- name: Init Env | |
run: | | |
git config --global user.email "[email protected]" | |
git config --global user.name "AuxXxilium" | |
sudo timedatectl set-timezone "Europe/Berlin" | |
sudo apt update | |
sudo apt install -y build-essential libtool pkgconf libzstd-dev liblzma-dev libssl-dev # kmodule dependencies | |
- name: Get Release Data for Arc | |
run: | | |
REPO="${{ github.server_url }}/${{ github.repository }}" | |
PRERELEASE="true" | |
TAG="" | |
if [ "${PRERELEASE}" = "true" ]; then | |
TAG="$(curl -skL --connect-timeout 10 "${REPO}/tags" | grep /refs/tags/.*\.zip | sed -r 's/.*\/refs\/tags\/(.*)\.zip.*$/\1/' | sort -rV | head -1)" | |
else | |
LATESTURL="$(curl -skL --connect-timeout 10 -w %{url_effective} -o /dev/null "${REPO}/releases/latest")" | |
TAG="${LATESTURL##*/}" | |
fi | |
[ "${TAG:0:1}" = "v" ] && TAG="${TAG:1}" | |
rm -f arc-${TAG}.img.zip | |
STATUS=$(curl -kL --connect-timeout 10 -w "%{http_code}" "${REPO}/releases/download/${TAG}/arc-${TAG}.img.zip" -o "arc-${TAG}.img.zip") | |
if [ $? -ne 0 -o ${STATUS:-0} -ne 200 ]; then | |
echo "Download failed" | |
exit 1 | |
fi | |
unzip arc-${TAG}.img.zip -d "arc" | |
sudo ./localbuild.sh create arc/ws arc/arc.img | |
if [ $? -ne 0 ]; then | |
echo "create failed" | |
exit 1 | |
fi | |
- name: Get data | |
run: | | |
pip install -r scripts/requirements.txt | |
python scripts/func.py getmodels -w "arc/ws" -j "docs/models.json" | |
python scripts/func.py getaddons -w "arc/ws" -j "docs/addons.json" | |
python scripts/func.py getmodules -w "arc/ws" -j "docs/modules.json" | |
python scripts/func.py getpats -w "arc/ws" -j "docs/pats.json" | |
- name: Upload to Artifacts | |
if: success() | |
uses: actions/upload-artifact@v4 | |
with: | |
name: docs | |
path: | | |
docs/*.json | |
retention-days: 5 | |
- name: Check and Push | |
if: success() && (inputs.push == true || github.event.action == 'created') | |
run: | | |
echo "Git push ..." | |
# git checkout main | |
git pull | |
status=$(git status -s | grep -E "docs" | awk '{printf " %s", $2}') | |
if [ -n "${status}" ]; then | |
git add ${status} | |
git commit -m "data: update $(date +%Y-%m-%d" "%H:%M:%S)" | |
git push -f | |
fi |