Yu-Gi-Oh! AE sets from Yugipedia #61
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
name: Yu-Gi-Oh! AE sets from Yugipedia | |
on: | |
# 8 PM UTC = 4 AM PST | |
# Every Friday UTC or Saturdays PST | |
schedule: | |
- cron: '0 20 * * 5' | |
# Manual triggers | |
workflow_dispatch: | |
inputs: | |
git-ref: | |
description: Git Ref (Optional) | |
required: false | |
clear-logs: | |
description: Clear 'logs' folder | 1 = true | |
required: false | |
clear-output: | |
description: Clear 'output' folder | 1 = true | |
required: false | |
clear-setlist-log: | |
description: Clear Setlist log | 1 = true | |
required: false | |
permissions: | |
contents: write | |
concurrency: | |
group: "yugipedia" | |
cancel-in-progress: true | |
env: | |
MAIN_BRANCH: main | |
REPO_BRANCH: yugipedia | |
FOLDER: Yugipedia | |
FOLDER_OUTPUT: output | |
FOLDER_LOGS: logs | |
FILE_SETDONE: setlist_done.log | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Clone repo, using branch name | |
uses: actions/checkout@v2 | |
if: github.event.inputs.git-ref == '' | |
with: | |
fetch-depth: 0 | |
ref: ${{ env.REPO_BRANCH }} | |
- name: Clone repo with ref | |
uses: actions/checkout@v2 | |
with: | |
fetch-depth: 0 | |
ref: ${{ github.event.inputs.git-ref }} | |
if: github.event.inputs.git-ref != '' | |
- name: Merge upstream 'main' branch into current branch | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git fetch origin ${{ env.MAIN_BRANCH }} | |
git merge origin/${{ env.MAIN_BRANCH }} | |
- name: Debugging files and refs (1) | |
working-directory: './${{ env.FOLDER }}' | |
run: | | |
ls -R . | |
git show-ref | |
- name: Clear logs subfolder | |
working-directory: './${{ env.FOLDER }}' | |
if: github.event.inputs.clear-logs == '1' | |
run: | | |
rm -r ${{ env.FOLDER_LOGS }} | |
- name: Clear output subfolder | |
working-directory: './${{ env.FOLDER }}' | |
if: github.event.inputs.clear-output == '1' | |
run: | | |
rm -r ${{ env.FOLDER_OUTPUT }} | |
- name: Clear setlist log file | |
working-directory: './${{ env.FOLDER }}' | |
if: github.event.inputs.clear-setlist-log == '1' | |
run: | | |
rm ${{ env.FILE_SETDONE }} | |
- name: Debugging files and refs (2) | |
working-directory: './${{ env.FOLDER }}' | |
run: | | |
ls -R . | |
git show-ref | |
- name: Install requirements.txt | |
working-directory: './${{ env.FOLDER }}' | |
run: pip install -r requirements.txt | |
- name: Run main python script | |
working-directory: './${{ env.FOLDER }}' | |
run: python main.py | |
- name: Commit to the repo | |
working-directory: './${{ env.FOLDER }}' | |
run: | | |
git config user.name "GitHub Actions" | |
git config user.email "[email protected]" | |
git add --all -- ':!*.html' | |
# "echo" returns true so the build succeeds, even if no changed files | |
git commit -m '[skip ci] Updated output folder contents' || echo | |
git push origin ${{ env.REPO_BRANCH }} |