Skip to content

Data

Data #1

Workflow file for this run

#
# Copyright (C) 2022 Ing <https://github.com/wjz304>
#
# This is free software, licensed under the MIT License.
# See /LICENSE for more information.
#
name: Data
on:
workflow_dispatch:
inputs:
push:
description: "push"
default: false
type: boolean
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@main
- name: Init Env
run: |
git config --global user.email "github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
sudo timedatectl set-timezone "Asia/Shanghai"
- name: Get models
run: |
models="{"
WORK_PATH="files/initrd/opt/rr"
for M in $(find "${WORK_PATH}/model-configs" -maxdepth 1 -name \*.yml 2>/dev/null | sed 's/.*\///; s/\.yml//'); do
models+="\"${M}\":["
for V in $(yq eval '.productvers | explode(.) | to_entries | map([.key])[] | .[]' "${WORK_PATH}/model-configs/${M}.yml" 2>/dev/null | sort -r); do
models+="\"${V}\","
done
models="${models%,}],"
done
models="${models%,}}"
echo "${models}" >docs/models.json
- name: Check and Push
if: success() && inputs.push == true
run: |
echo "Git push ..."
git pull
status=$(git status -s | grep -E 'docs/models.json' | awk '{printf " %s", $2}')
if [ -n "${status}" ]; then
git add ${status}
git commit -m "update $(date +%Y-%m-%d" "%H:%M:%S)"
git push -f
fi