-
Notifications
You must be signed in to change notification settings - Fork 9
82 lines (77 loc) · 3.06 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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# 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:
- uses: actions/setup-python@v2
- name: install dependencies
run: |
python -m pip install --upgrade pip
pip install openai loguru tenacity gitpython PyGithub
# 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'
# this needs to run before the checkout becaue it will result in remotely generated commits
# ... but then we won't have the scripts directory. so checkout first, then pull after i guess
- name: migrate notes in issues
run: |
#git config --local user.name "Github Action"
#git config --local user.email "action@github.com"
python scripts/migrate_issues.py
git pull origin
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
## - name: Predict tags
## if: env.OPENAI_API_KEY != ''
## run: python scripts/tag.py
## env:
## OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
# - name: move entries to subdir and commit
# run: |
# for file in *.md; do
# if [ "$file" != "README.md" ] && [ "$file" != "FAQ.md" ]; then
# git mv "$file" entries/
# fi
# done
# git config --local user.name "Github Action"
# git config --local user.email "action@github.com"
# git add entries/*.md
# # 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: 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 "action@github.com"
git add *.md
git add tags/*.md
# 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