Skip to content

Check for updates

Check for updates #18

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'
pull_request:
branches:
- main
paths:
- 'main.py'
- '.github/ISSUE_TEMPLATE.md'
- '.github/workflows/check-for-updates.yml'
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) }} # commit changes only if scheduled
uses: EndBug/[email protected]
with:
message: "Update last_update.json"
add: last_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: last_update
path: ./last_update.json
create-issue:
needs: check-for-updates
if: ${{ !contains(fromJSON('["push", "pull_request"]'), github.event_name) && needs.check-for-updates.outputs.updated == 'yes' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Download artifact
uses: actions/download-artifact@v4
with:
name: last_update
- name: Get data from json
id: get_data
run: echo "json_data=$(cat last_update.json)" >> $GITHUB_OUTPUT
- 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 }}