This repository has been archived by the owner on Aug 9, 2024. It is now read-only.
ci: update global workflows #390
Workflow file for this run
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: Update | |
on: | |
pull_request: | |
branches: [master, nightly] | |
types: [opened, synchronize, reopened] | |
push: | |
branches: [master] | |
schedule: | |
- cron: '0 12 * * *' # every day at noon | |
workflow_dispatch: | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
update_database: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Checkout database | |
uses: actions/checkout@v4 | |
with: | |
ref: database | |
path: database | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token | |
fetch-depth: 0 # otherwise, will fail to push refs to dest repo | |
- name: Get current date | |
id: date | |
shell: bash | |
run: | | |
echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Set up Python | |
uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- name: Install Python dependencies | |
run: | | |
python -m pip install --upgrade pip setuptools wheel | |
python -m pip install -r requirements.txt | |
- name: Update | |
env: | |
GH_TOKEN: ${{ github.token }} | |
PAT_TOKEN: ${{ secrets.GH_BOT_TOKEN }} | |
run: | | |
python -u ./updater.py --daily_update | |
- name: Upload Artifacts | |
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: database | |
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` | |
path: | | |
${{ github.workspace }}/database | |
!**/*.git | |
- name: GitHub Commit & Push | |
if: >- | |
(github.event_name == 'push' && github.ref == 'refs/heads/master') || | |
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') | |
uses: actions-js/[email protected] | |
with: | |
author_email: ${{ secrets.GH_BOT_EMAIL }} | |
author_name: ${{ secrets.GH_BOT_NAME }} | |
branch: database # commit to database | |
directory: database # use the database directory | |
github_token: ${{ secrets.GH_BOT_TOKEN }} | |
message: automatic-update-${{ steps.date.outputs.date }} | |
update_pages: | |
needs: [update_database] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Checkout database | |
uses: actions/checkout@v4 | |
with: | |
ref: database | |
path: database | |
- name: Checkout gh-pages | |
uses: actions/checkout@v4 | |
with: | |
ref: gh-pages | |
path: gh-pages | |
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token | |
fetch-depth: 0 # otherwise, will fail to push refs to dest repo | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT | |
- name: Prepare gh-pages | |
run: | | |
# empty contents | |
rm -f -r ./gh-pages/* | |
# copy template back to pages | |
cp -f -r ./gh-pages-template/. ./gh-pages/ | |
# copy database back to pages | |
rm -rf ./database/.git # remove git directory | |
cp -f -r ./database/. ./gh-pages/ | |
- name: Upload Artifacts | |
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} | |
uses: actions/upload-artifact@v3 | |
with: | |
name: gh-pages | |
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` | |
path: | | |
${{ github.workspace }}/gh-pages | |
!**/*.git | |
- name: Deploy to gh-pages | |
if: >- | |
(github.event_name == 'push' && github.ref == 'refs/heads/master') || | |
(github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') | |
uses: actions-js/[email protected] | |
with: | |
github_token: ${{ secrets.GH_BOT_TOKEN }} | |
author_email: ${{ secrets.GH_BOT_EMAIL }} | |
author_name: ${{ secrets.GH_BOT_NAME }} | |
directory: gh-pages | |
branch: gh-pages | |
force: true | |
message: automatic-update-${{ steps.date.outputs.date }} |