mirror of
https://gitlab.com/vcheckzen/KeepAliveE5
synced 2026-03-18 15:53:17 +08:00
reset
This commit is contained in:
99
.github/workflows/register.yml
vendored
Normal file
99
.github/workflows/register.yml
vendored
Normal file
@@ -0,0 +1,99 @@
|
||||
name: Register APP
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
Register:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event.repository.private }}
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
token: ${{ secrets.PAT }}
|
||||
|
||||
- name: Sync with upstream
|
||||
run: bash wrapper.sh pull
|
||||
|
||||
- name: Check environment variables
|
||||
env:
|
||||
USER: ${{ secrets.USER }}
|
||||
PASSWD: ${{ secrets.PASSWD }}
|
||||
run: bash wrapper.sh check_env
|
||||
|
||||
- name: Setup nodejs
|
||||
id: setup-nodejs
|
||||
uses: actions/setup-node@v4
|
||||
with:
|
||||
node-version: 18.14
|
||||
# cache: 'npm'
|
||||
# cache-dependency-path: '**/package.json'
|
||||
|
||||
- name: Set up python
|
||||
id: setup-python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Load cached utils
|
||||
id: cached-utils
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.local
|
||||
key: ${{ runner.os }}-utils-az-poetry-20241024
|
||||
restore-keys: |
|
||||
${{ runner.os }}-utils-
|
||||
|
||||
# - name: Check utils version
|
||||
# id: utils-version
|
||||
# run: |
|
||||
# echo "~/.local/bin" >> $GITHUB_PATH
|
||||
# {
|
||||
# export PATH=~/.local/bin:$PATH
|
||||
# [ "$(az version -o tsv --query "\"azure-cli\"")" = "2.39.0" ] && echo "az=true"
|
||||
# poetry -V | grep -q 1.3.2 && echo "poetry=true"
|
||||
# } 2>/dev/null | tee -a $GITHUB_OUTPUT || true
|
||||
|
||||
- name: Install poetry
|
||||
# if: steps.utils-version.outputs.poetry != 'true'
|
||||
if: steps.cached-utils.outputs.cache-hit != 'true'
|
||||
uses: snok/install-poetry@v1
|
||||
with:
|
||||
version: 1.3.2
|
||||
virtualenvs-create: true
|
||||
virtualenvs-in-project: true
|
||||
installer-parallel: true
|
||||
|
||||
- name: Load cached venv
|
||||
id: cached-poetry-dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: .venv
|
||||
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-venv-${{ hashFiles('**/poetry.lock') }}
|
||||
|
||||
- name: Install python dependencies
|
||||
if: steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||
run: poetry install --no-interaction --no-root --only main
|
||||
|
||||
- name: Load cached node dependencies
|
||||
id: cached-node-dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: register/node_modules
|
||||
key: ${{ runner.os }}-node-${{ steps.setup-nodejs.outputs.node-version }}-pkg-${{ hashFiles('**/package.json') }}
|
||||
|
||||
- name: Install node dependencies
|
||||
if: steps.cached-node-dependencies.outputs.cache-hit != 'true'
|
||||
run: cd register && npm install
|
||||
|
||||
- name: Register apps
|
||||
env:
|
||||
USER: ${{ secrets.USER }}
|
||||
PASSWD: ${{ secrets.PASSWD }}
|
||||
run: bash wrapper.sh register
|
||||
|
||||
- name: Commit and push
|
||||
run: bash wrapper.sh push "generate app config"
|
||||
138
.github/workflows/routine.yml
vendored
Normal file
138
.github/workflows/routine.yml
vendored
Normal file
@@ -0,0 +1,138 @@
|
||||
name: Invoke API
|
||||
|
||||
on:
|
||||
schedule:
|
||||
- cron: '7 1,5,10,14,17,22 * * *'
|
||||
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#providing-inputs
|
||||
workflow_dispatch:
|
||||
inputs:
|
||||
unconditional-invoking:
|
||||
description: 'Invoke API unconditionally'
|
||||
type: boolean
|
||||
required: true
|
||||
default: true
|
||||
|
||||
# https://github.com/actions/checkout/issues/19
|
||||
jobs:
|
||||
# Random:
|
||||
# runs-on: ubuntu-latest
|
||||
# outputs:
|
||||
# runnable: ${{ steps.decision.outputs.runnable }}
|
||||
# steps:
|
||||
# - name: Checkout code
|
||||
# uses: actions/checkout@v3
|
||||
# with:
|
||||
# ref: master
|
||||
# token: ${{ secrets.PAT }}
|
||||
|
||||
# - name: Pull upstream
|
||||
# run: bash wrapper.sh pull sync
|
||||
|
||||
# - name: Commit and push
|
||||
# run: bash wrapper.sh push "sync with upstream"
|
||||
|
||||
# - name: Make a decision
|
||||
# id: decision
|
||||
# env:
|
||||
# PASSWD: ${{ secrets.PASSWD }}
|
||||
# run: |
|
||||
# sum=$(cksum <<< "$PASSWD" | cut -f1 -d' ')
|
||||
# m=$(date "+%-m")
|
||||
# d=$(date "+%-d")
|
||||
# h=$(date "+%-H")
|
||||
# [ $(((d + m + sum) % 6)) = 1 ] && exit 0
|
||||
# [ $(((h + d + sum) & 1)) = 1 ] && exit 0
|
||||
# echo "::set-output name=runnable::true"
|
||||
|
||||
Invoke:
|
||||
runs-on: ubuntu-latest
|
||||
if: ${{ github.event.repository.private }}
|
||||
# needs: Random
|
||||
# if: needs.Random.outputs.runnable == 'true'
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v4
|
||||
with:
|
||||
ref: master
|
||||
token: ${{ secrets.PAT }}
|
||||
|
||||
- name: Sync with upstream
|
||||
run: bash wrapper.sh pull
|
||||
|
||||
- name: Check config files
|
||||
env:
|
||||
USER: ${{ secrets.USER }}
|
||||
run: |
|
||||
bash wrapper.sh has_valid_cfg || {
|
||||
echo "Config files are not valid, please run Register App action."
|
||||
exit 1
|
||||
}
|
||||
|
||||
- name: Make a decision
|
||||
id: decision
|
||||
env:
|
||||
PASSWD: ${{ secrets.PASSWD }}
|
||||
run: |
|
||||
[ "${{ inputs.unconditional-invoking }}" = "true" ] && {
|
||||
echo "runnable=true" >> $GITHUB_OUTPUT
|
||||
exit 0
|
||||
}
|
||||
|
||||
sum=$(cksum <<< "$PASSWD" | cut -f1 -d' ')
|
||||
m=$(date "+%-m")
|
||||
d=$(date "+%-d")
|
||||
h=$(date "+%-H")
|
||||
[ $(((d + m + sum) % 6)) = 1 ] && exit 0
|
||||
[ $(((h + d + sum) & 1)) = 1 ] && exit 0
|
||||
# echo "::set-output name=runnable::true"
|
||||
echo "runnable=true" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Set up python
|
||||
if: steps.decision.outputs.runnable == 'true'
|
||||
id: setup-python
|
||||
uses: actions/setup-python@v5
|
||||
with:
|
||||
python-version: '3.10'
|
||||
|
||||
- name: Load cached utils
|
||||
if: steps.decision.outputs.runnable == 'true'
|
||||
id: cached-utils
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: ~/.local
|
||||
key: ${{ runner.os }}-utils-az-poetry-20241016
|
||||
restore-keys: |
|
||||
${{ runner.os }}-utils-
|
||||
|
||||
- name: Install poetry
|
||||
if: steps.decision.outputs.runnable == 'true' && steps.cached-utils.outputs.cache-hit != 'true'
|
||||
uses: snok/install-poetry@v1
|
||||
with:
|
||||
version: 1.3.2
|
||||
virtualenvs-create: true
|
||||
virtualenvs-in-project: true
|
||||
installer-parallel: true
|
||||
|
||||
- name: Load cached venv
|
||||
if: steps.decision.outputs.runnable == 'true'
|
||||
id: cached-poetry-dependencies
|
||||
uses: actions/cache@v4
|
||||
with:
|
||||
path: .venv
|
||||
key: ${{ runner.os }}-python-${{ steps.setup-python.outputs.python-version }}-venv-${{ hashFiles('**/poetry.lock') }}
|
||||
|
||||
- name: Install python dependencies
|
||||
if: steps.decision.outputs.runnable == 'true' && steps.cached-poetry-dependencies.outputs.cache-hit != 'true'
|
||||
run: poetry install --no-interaction --no-root --only main
|
||||
|
||||
- name: Test API
|
||||
if: steps.decision.outputs.runnable == 'true'
|
||||
env:
|
||||
USER: ${{ secrets.USER }}
|
||||
PASSWD: ${{ secrets.PASSWD }}
|
||||
run: bash wrapper.sh invoke
|
||||
|
||||
- name: Commit and push
|
||||
if: steps.decision.outputs.runnable == 'true'
|
||||
run: bash wrapper.sh push "update app config"
|
||||
Reference in New Issue
Block a user