-
Notifications
You must be signed in to change notification settings - Fork 27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
script for .diff parsing #193
Conversation
OK - looks like a good start. Now let's think about a way to integrate this with the desired workflow. We need a GitHub Action that runs only when a PR is merged. Here's what the documentation suggests to do in this case: on:
pull_request:
types:
- closed
jobs:
if_merged:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
steps:
- run: |
echo The PR was merged We want to be even more specific and only let the action run if the PR has a certain name. I think this could be be done like this: on:
pull_request:
types:
- closed
jobs:
if_merged:
if: |
github.event.pull_request.merged == true &&
github.event.pull_request.title == "[Automatic PR] Update chronicle file"
runs-on: ubuntu-latest
steps:
- run: |
echo The PR was merged But this is for the future. For developing I suggest to go with manual dispatch for now. That allows to manually trigger the workflow. on:
workflow_dispatch: # for manual dispatch
jobs:
if_merged:
runs-on: ubuntu-latest
steps:
- name: Install python and dependencies
run: <What goes here?>
- name: Run diff parsing script
run: ./Parsing_new_package_diff/parse_diff.py Because you first of all have to find a minimal (!) setup to install the necessary dependencies for your script and then run it for a URL that provides the text file with a relevant diff. For developing you can use a hardcoded one (e.g. At the beginning just let the script print its output to the console, so that you can see if it works reliably. Only in the very last step we should add the action that posts to mastodon. |
I have updated the script in order to give a console output. Regarding triggering the action, Can we trigger it when a PR with a specific label gets merged? |
Yes - that's exactly what I tried to explain above. |
I was thinking about the following approach . The job runs only if the PR is merged. Then sets up python and install dependencies if necessary. Afterwards Fetches the diff file from the PR URL and saves it as diff.txt and runs this python script on that
Does this look accurate? |
The general order of events sounds correct to me. The syntax of the script is a bit off, though. Btw. you can write multi-line code blocks in GitHub Markdown as documented here. This even supports syntax highlighting if you write the language after the first triple backticks: ```yml. |
I have added a draft version of the yml file which fetches diff information when github.event.pull_request.merged is True. Then parse those information using the above given python script |
OK! Does it work? If you add on:
workflow_dispatch: and temporarily replace the code to construct the diff url with a hardcoded one like this - name: Construct diff URL
id: construct_diff_url
run: |
echo "https://patch-diff.githubusercontent.com/raw/poseidon-framework/community-archive/pull/184.diff" > diff_url.txt then you should be able to test it. |
This PR was superseded by #194 |
Following python script fetch the content of a .diff file and parse it to extract the new package information