Merge pull request #1 from tsalemink/main #1
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-database | |
on: | |
# Triggers the workflow on issue close. | |
issues: | |
types: [closed] | |
# Allows you to run this workflow manually from the Actions tab. | |
workflow_dispatch: | |
# If we make any changes to the repository manually, this will ensure that the database stays up-to-date with the timestamp on the repo. | |
push: | |
jobs: | |
update-database: | |
# If the workflow was triggered by closing an issue, only run if the issue contains the 'add-plugin' label. | |
if: ${{ github.event_name == 'workflow_dispatch' }} or ${{ github.event.label.name == 'add-plugin' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repo content | |
uses: actions/checkout@v4 | |
- name: Retrieve database timestamp | |
id: time | |
run: echo "time=${{ github.event.repository.updated_at }}" >> $GITHUB_OUTPUT | |
- name: Retrieve URL submission | |
id: url | |
run: | | |
if ${{ github.event_name == 'issues' }}; then | |
echo "url=${{ github.event.issue.body }}" >> $GITHUB_OUTPUT | |
else | |
echo "url=''" >> $GITHUB_OUTPUT | |
fi | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install Python packages | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r generation/requirements.txt | |
- name: Run Python script | |
run: python generation/update_database.py ${{ steps.time.outputs.time }} ${{ steps.url.outputs.url }} | |
env: | |
GITHUB_TOKEN: ${{ github.token }} | |
- name: Commit files | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Action" | |
git add -A | |
git diff-index --quiet HEAD || (git commit -a -m "Update database." --allow-empty) | |
- name: Push changes | |
uses: ad-m/[email protected] | |
with: | |
github_token: ${{ secrets.GITHUB_TOKEN }} | |
branch: main |