Check for updates #9320
This file contains hidden or 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: Check for updates | |
| on: | |
| schedule: | |
| - cron: "0 * * * *" | |
| workflow_dispatch: | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - 'main.py' | |
| - '.github/ISSUE_TEMPLATE.md' | |
| - '.github/workflows/check-for-updates.yml' | |
| - 'pyproject.toml' | |
| - 'uv.lock' | |
| pull_request: | |
| branches: | |
| - main | |
| paths: | |
| - 'main.py' | |
| - '.github/ISSUE_TEMPLATE.md' | |
| - '.github/workflows/check-for-updates.yml' | |
| - 'pyproject.toml' | |
| - 'uv.lock' | |
| permissions: | |
| contents: write | |
| issues: write | |
| jobs: | |
| check-for-updates: | |
| runs-on: ubuntu-latest | |
| outputs: | |
| updated: ${{ steps.script.outputs.updated }} | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Set up Python | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: 3.12 | |
| - name: Install uv | |
| uses: astral-sh/setup-uv@v7.3.1 | |
| with: | |
| version: "latest" | |
| - name: Run script | |
| id: script | |
| run: echo "updated=$(uv run main.py)" >> $GITHUB_OUTPUT | |
| - name: Commit changes | |
| if: ${{ !contains(fromJSON('["push", "pull_request"]'), github.event_name) && steps.script.outputs.updated == 'yes' }} | |
| uses: EndBug/add-and-commit@v9.1.4 | |
| with: | |
| message: "Update latest_update.json, releases.rss" | |
| add: latest_update.json releases.rss | |
| author_name: github-actions[bot] | |
| author_email: 41898282+github-actions[bot]@users.noreply.github.com | |
| - name: Upload artifact | |
| uses: actions/upload-artifact@v7 | |
| if: ${{ steps.script.outputs.updated == 'yes' }} | |
| with: | |
| name: full_update_info | |
| path: ./full_update_info.json | |
| create-issue: | |
| if: ${{ !contains(fromJSON('["push", "pull_request"]'), github.event_name) && needs.check-for-updates.outputs.updated == 'yes' }} | |
| needs: check-for-updates | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| - name: Download artifact | |
| uses: actions/download-artifact@v8 | |
| with: | |
| name: full_update_info | |
| - name: Get data from json | |
| id: get_data | |
| run: echo "json_data=$(cat full_update_info.json)" >> $GITHUB_OUTPUT | |
| - name: Print data | |
| run: | | |
| echo "TITLE: ${{ fromJson(steps.get_data.outputs.json_data).title }}" | |
| echo "CONTENTS: ${{ fromJson(steps.get_data.outputs.json_data).contents }}" | |
| echo "URL: ${{ fromJson(steps.get_data.outputs.json_data).url }}" | |
| echo "AUTHOR: ${{ fromJson(steps.get_data.outputs.json_data).author }}" | |
| - name: Create issue | |
| uses: JasonEtco/create-an-issue@v2 | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| TITLE: ${{ fromJson(steps.get_data.outputs.json_data).title }} | |
| CONTENTS: ${{ fromJson(steps.get_data.outputs.json_data).contents }} | |
| URL: ${{ fromJson(steps.get_data.outputs.json_data).url }} | |
| AUTHOR: ${{ fromJson(steps.get_data.outputs.json_data).author }} |