How to trigger a GitHub action only when the response of a script is different and it changes a particular file #24919
-
Use case: I’m having a python script to fetch a ICS (iCalendar) feed, which parses the ICS into a YAML file. How can I create a GitHub action, which will schedule the script to run every day and check whether after it’s execution, the YAML files changes or not. If the YAML file changes, then only it might send a PR |
Beta Was this translation helpful? Give feedback.
Replies: 8 comments
-
You can use a scheduled event to trigger the workflow. As for detecting changes I’d suggest just overwriting the YAML file and then using |
Beta Was this translation helpful? Give feedback.
-
Hey, thanks for your reply! Do you mean something like this with a scheduled event:
Is there any other way to do this? |
Beta Was this translation helpful? Give feedback.
-
Close, but you can’t use a shell command directly in the
|
Beta Was this translation helpful? Give feedback.
-
I really appreciate for your help, thank youu! |
Beta Was this translation helpful? Give feedback.
-
Hey, I’m not sure why it’s saying it’s not a git repository. Thus all the jobs run successfully, but no changes occur |
Beta Was this translation helpful? Give feedback.
-
Did you use If yes check its logs. By default it creates a Git repository, but if the installed Git version is too old (that might happen with a job container or self-hosted runner) it might just download the files over the API. |
Beta Was this translation helpful? Give feedback.
-
Yes, I used actions/checkout before these. I think in this, the git is initialized: |
Beta Was this translation helpful? Give feedback.
-
Looks like it is, but the working directory looks odd with the |
Beta Was this translation helpful? Give feedback.
Close, but you can’t use a shell command directly in the
if
condition. You’ll have to use an extra step to set an output or environment variable, e.g.: