-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit b25bd51
Showing
25 changed files
with
2,671 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
name: Register APP | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
jobs: | ||
Register: | ||
runs-on: ubuntu-latest | ||
if: ${{ github.event.repository.private }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
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@v3 | ||
with: | ||
node-version: 18.14.2 | ||
# cache: 'npm' | ||
# cache-dependency-path: '**/package.json' | ||
|
||
- name: Set up python | ||
id: setup-python | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.10.10' | ||
|
||
- name: Load cached utils | ||
id: cached-utils | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.local | ||
key: ${{ runner.os }}-utils-az-poetry-20230204 | ||
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 | ||
|
||
# https://github.com/Azure/azure-cli/issues/7124 | ||
- name: Install specific version of azure-cli | ||
if: steps.cached-utils.outputs.cache-hit != 'true' | ||
run: | | ||
[ "$(az version -o tsv --query "\"azure-cli\"")" = "2.39.0" ] && exit 0 | ||
sudo apt-get remove azure-cli -y | ||
sudo apt-get autoremove -y | ||
# the default variables are fine | ||
# PIPX_HOME=~/.local/pipx PIPX_BIN_DIR=~/.local/bin pipx install azure-cli==2.39.0 | ||
pipx install azure-cli==2.39.0 | ||
# this path has been added by the previous step | ||
# echo "~/.local/bin" >> $GITHUB_PATH | ||
- name: Load cached venv | ||
id: cached-poetry-dependencies | ||
uses: actions/cache@v3 | ||
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@v3 | ||
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" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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@v3 | ||
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@v4 | ||
with: | ||
python-version: '3.10.10' | ||
|
||
- name: Load cached utils | ||
if: steps.decision.outputs.runnable == 'true' | ||
id: cached-utils | ||
uses: actions/cache@v3 | ||
with: | ||
path: ~/.local | ||
key: ${{ runner.os }}-utils-az-poetry-20230204 | ||
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@v3 | ||
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" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
# Byte-compiled / optimized / DLL files | ||
__pycache__/ | ||
*.py[cod] | ||
*$py.class | ||
|
||
# C extensions | ||
*.so | ||
|
||
# Distribution / packaging | ||
.Python | ||
build/ | ||
develop-eggs/ | ||
dist/ | ||
downloads/ | ||
eggs/ | ||
.eggs/ | ||
lib/ | ||
lib64/ | ||
parts/ | ||
sdist/ | ||
var/ | ||
wheels/ | ||
share/python-wheels/ | ||
*.egg-info/ | ||
.installed.cfg | ||
*.egg | ||
MANIFEST | ||
|
||
# PyInstaller | ||
# Usually these files are written by a python script from a template | ||
# before PyInstaller builds the exe, so as to inject date/other infos into it. | ||
*.manifest | ||
*.spec | ||
|
||
# Installer logs | ||
pip-log.txt | ||
pip-delete-this-directory.txt | ||
|
||
# Unit test / coverage reports | ||
htmlcov/ | ||
.tox/ | ||
.nox/ | ||
.coverage | ||
.coverage.* | ||
.cache | ||
nosetests.xml | ||
coverage.xml | ||
*.cover | ||
*.py,cover | ||
.hypothesis/ | ||
.pytest_cache/ | ||
cover/ | ||
|
||
# Translations | ||
*.mo | ||
*.pot | ||
|
||
# Django stuff: | ||
*.log | ||
local_settings.py | ||
db.sqlite3 | ||
db.sqlite3-journal | ||
|
||
# Flask stuff: | ||
instance/ | ||
.webassets-cache | ||
|
||
# Scrapy stuff: | ||
.scrapy | ||
|
||
# Sphinx documentation | ||
docs/_build/ | ||
|
||
# PyBuilder | ||
.pybuilder/ | ||
target/ | ||
|
||
# Jupyter Notebook | ||
.ipynb_checkpoints | ||
|
||
# IPython | ||
profile_default/ | ||
ipython_config.py | ||
|
||
# pyenv | ||
# For a library or package, you might want to ignore these files since the code is | ||
# intended to run in multiple environments; otherwise, check them in: | ||
# .python-version | ||
|
||
# pipenv | ||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control. | ||
# However, in case of collaboration, if having platform-specific dependencies or dependencies | ||
# having no cross-platform support, pipenv may install dependencies that don't work, or not | ||
# install all needed dependencies. | ||
#Pipfile.lock | ||
|
||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow | ||
__pypackages__/ | ||
|
||
# Celery stuff | ||
celerybeat-schedule | ||
celerybeat.pid | ||
|
||
# SageMath parsed files | ||
*.sage.py | ||
|
||
# Environments | ||
.env | ||
.venv | ||
env/ | ||
venv/ | ||
ENV/ | ||
env.bak/ | ||
venv.bak/ | ||
|
||
# Spyder project settings | ||
.spyderproject | ||
.spyproject | ||
|
||
# Rope project settings | ||
.ropeproject | ||
|
||
# mkdocs documentation | ||
/site | ||
|
||
# mypy | ||
.mypy_cache/ | ||
.dmypy.json | ||
dmypy.json | ||
|
||
# Pyre type checker | ||
.pyre/ | ||
|
||
# pytype static type analyzer | ||
.pytype/ | ||
|
||
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# Runtime files | ||
utils.meta |
Oops, something went wrong.