Skip to content

CI

CI #152

Workflow file for this run

# This is a basic workflow to help you get started with Actions
name: CI
# Controls when the workflow will run
on:
# Triggers the workflow on push or pull request events but only for the main branch
# push:
# branches: [ main ]
pull_request:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
schedule:
# https://crontab.guru
- cron: 0 18 * * 0
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "build"
build:
# The type of runner that the job will run on
runs-on: ubuntu-latest
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- name: 初始化Python
uses: actions/setup-python@v2
with:
python-version: 3.7
- run: |
pip install -r tools/requirements.txt
mv tools/image.py ./image.py
- name: Cache update time
id: cache-updated
uses: actions/cache@v3
with:
key: npm-${{ hashFiles('package-lock.json') }}
path: |
~/updatedAt
- name: Checkout tools repo
uses: actions/checkout@v2
with:
repository: laynH/Anime-Girls-Holding-Programming-Books
path: tools
- if: ${{ steps.cache-updated.outputs.cache-hit != 'true' }}
name: image w/o cache
run: |
cd tools
echo ${{ secrets.CLOUDINARY_URL }}
export CLOUDINARY_URL=${{ secrets.CLOUDINARY_URL }}
mv ../image.py ./image.py
UPDATE=`curl https://api.github.com/repositories/90916769 | jq .updated_at`
echo $UPDATE > ~/updatedAt
python image.py upload
cd ..
- if: ${{ steps.cache-updated.outputs.cache-hit == 'true' }}
name: image w/ cache
run: |
cd tools
echo ${{ secrets.CLOUDINARY_URL }}
export CLOUDINARY_URL=${{ secrets.CLOUDINARY_URL }}
mv ../image.py ./image.py
UPDATE=`curl https://api.github.com/repositories/90916769 | jq .updated_at`
UPDATECACHE=`cat ~/updatedAt`
echo $UPDATE $UPDATECACHE
if [ "$UPDATE" = "$UPDATECACHE" ]; then
echo "Strings are equal."
exit 0
else
echo "Strings are not equal."
python image.py upload
echo $UPDATE > ~/updatedAt
fi
cd ..
# - name: Use Node.js
# uses: actions/setup-node@v2
# with:
# node-version: 14.x
# - run: npm install
- name: Commit and push if changed
run: |
git status
cat src/itemData.js
if [[ -n $(git --no-pager diff src/itemData.js) ]]
then
echo 'dirty'
git config user.name github-actions
git config user.email github-actions@github.com
git add src/itemData.js
git commit -m "Github Action Auto Updated"
git push
else
echo 'clean'
fi