Run workflow on changes in pyproject.toml and uv.lock #22
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: Check for updates | |
on: | |
schedule: | |
- cron: "0 0,6,12,18 * * *" | |
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@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: 3.12 | |
- name: Install uv | |
uses: astral-sh/[email protected] | |
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) }} | |
uses: EndBug/[email protected] | |
with: | |
message: "Update latest_update.json" | |
add: latest_update.json | |
author_name: github-actions[bot] | |
author_email: 41898282+github-actions[bot]@users.noreply.github.com | |
- name: Upload artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: latest_update | |
path: ./latest_update.json | |
create-issue: | |
needs: check-for-updates | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Download artifact | |
uses: actions/download-artifact@v4 | |
with: | |
name: latest_update | |
- name: Get data from json | |
id: get_data | |
run: echo "json_data=$(cat latest_update.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 | |
if: ${{ !contains(fromJSON('["push", "pull_request"]'), github.event_name) && needs.check-for-updates.outputs.updated == 'yes' }} | |
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 }} |