Skip to content
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

fix: ignore forks #250

Merged
merged 6 commits into from Sep 18, 2023
Merged

fix: ignore forks #250

merged 6 commits into from Sep 18, 2023

Conversation

laurentsenta
Copy link
Contributor

@laurentsenta laurentsenta commented Sep 18, 2023

Contributes to #249

When working with the GitHub API, a run originating from a fork might still have the same branch name (e.g., master) as the parent repository. To filter out runs from forks, we check the head_repository attribute of the run. This attribute contains information about the repository where the head of the pull request is stored.

@dawidd6
Copy link
Owner

dawidd6 commented Sep 18, 2023

Nice but I think this should be guarded by a new action input, defaulting to false, as it could break some existing workflows based on PRs I guess.

@laurentsenta
Copy link
Contributor Author

laurentsenta commented Sep 18, 2023

I would recommend against making it default, there is no way someone writing the following code intended to load artifacts from any fork from the internet:

- name: Download artifact
  id: download-artifact
  uses: dawidd6/action-download-artifact@v2
  with:
    branch: master

We wouldn't have caught it if our target workflow didn't require approval on the first run.

What do you want the input name to be?

@laurentsenta
Copy link
Contributor Author

laurentsenta commented Sep 18, 2023

proposed a version that might work for both of us, I'm testing it out right now; let me know if that model works for you. Otherwise I'll do the simple flag.

@laurentsenta
Copy link
Contributor Author

Ready for merge, used in yaml, run

DOWNLOAD JSON OUTPUT
==> Repository: ipfs/kubo
==> Artifact name: gateway-conformance.json
==> Local path: ./
==> Workflow name: gateway-conformance.yml
==> Branch: master
==> Allow forks: false
...
==> Skipping run from fork: patrickReiis/kubo
==> Skipping run from fork: patrickReiis/kubo
...

action.yml Show resolved Hide resolved
main.js Outdated Show resolved Hide resolved
main.js Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
Co-authored-by: Dawid Dziurla <dawidd0811@gmail.com>
@dawidd6
Copy link
Owner

dawidd6 commented Sep 18, 2023

Very nice. Thanks for contribution!

@dawidd6 dawidd6 merged commit 2686771 into dawidd6:master Sep 18, 2023
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants