49 group anagrams #9
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
# 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 |