repository-traffic-action
repository-traffic-action copied to clipboard
Action will fail in forks
Thanks for this very handy action. The problem I encountered is that the action will fail for anyone forking the repo since it relies on a PAT. Any ideas for a workaround?
Hi @thias15! Should a forked repositories views and clones count towards the upstream repository? Do you know what GitHub does for this scenario?
I think I would expect a forked repos stats to be separate from the upstream repo, given that forked repo can become it's own separate thing.
Either way I don't think there is anything that can be done, apart from the person who forked creating a PAT and using it to log metrics for the fork.
It would be nice to have the repo name as an input rather than using GITHUB_REPOSITORY
Sorry, hadn't seen your latest comment. I think it would be reasonable to let the user override GITHUB_REPOSITORY with their own value by setting an env variable. By the way have you tried overriding GITHUB_REPOSITORY by setting it on the yaml file? Something along the lines of:
- name: GitHub traffic
uses: sangonzal/[email protected]
env:
TRAFFIC_ACTION_TOKEN: ${{ secrets.TRAFFIC_ACTION_TOKEN }}
GITHUB_REPOSITORY: name_you_want_to_use
I don't have time to make the changes and test right now, but if you'd like to make the change I would merge the pull request in and release a new version.
Hi @sangonzal 👋🏽 I've tried your suggestion about using the GITHUB_REPOSITORY
env but couldn't get it to work.
I'm running your action from the innovyze/Traffic-Data
repository on traffic from the innovyze/Open-Source-Support
repository.
See below:
It seems that the environment variable has been recognised, but the action is still being applied to traffic in the innovyze/Traffic-Data
repository.
Do you know what I'm getting wrong?
Hi @dfmore, I haven't actually tried to do this before, so I don't know if overriding GITHUB_REPOSITORY actually works. From your screenshot, it seems that Github might not allow you to override env variables that they set.
Another way of going about this is to define another env variable, something like REPOSITORY_NAME, and check in main.py if it's set. If REPOSITORY_NAME is set, then use it, if not then fallback to GITHUB_REPOSITORY.
I don't have time to make the changes right now and test, but happy to merge in a PR with these changes. Next time I do have time to work on the project I'll see if I can get this in.