generated from dmarx/workbench
-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (49 loc) · 1.85 KB
/
main.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
# This is a basic workflow to help you get started with Actions
name: update-readme
# Controls when the workflow will run
on:
push:
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
# 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:
runs-on: ubuntu-latest
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
# https://stackoverflow.com/questions/60868897/git-log-dates-incorrect-in-a-github-action
- uses: actions/checkout@v3
with:
fetch-depth: '0'
- uses: actions/setup-python@v2
- name: install dependencies
run: pip install openai tenacity #loguru
- name: Predict tags
# skip this step if api key not provided
if: env.OPENAI_API_KEY != ''
run: python scripts/tag.py
env:
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
- name: Build README
run: python scripts/update_readme.py
- name: Commit files
#if: "! git status --short" # check if there are changes to commit
run: |
git config --local user.name "Github Action"
git config --local user.email "[email protected]"
git add *.md
git add tags/*
# Thanks for the trick, ChatGPT!
if git diff-index --quiet HEAD --; then
echo "changes_to_push=false" >> $GITHUB_ENV
else
git commit -m "Updated TOC"
echo "changes_to_push=true" >> $GITHUB_ENV
fi
- name: Push changes # push the output folder to your repo
if: ${{ env.changes_to_push == 'true' }}
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
force: true