BioDrop icon indicating copy to clipboard operation
BioDrop copied to clipboard

[OTHER] Add Repository Condition to GitHub Actions to Prevent Execution in Forked Repositories

Open weilincheng opened this issue 3 years ago • 14 comments

What would you like to share?

Upon syncing the forked repository, I observed that the Storybook and Deploy releases to Vercel GitHub Actions were being triggered and subsequently failing. Here's a screenshot for reference: image

I discovered that these two Actions lack a conditional check to ensure they only run in the EddieHubCommunity/LinkFree repository, which leads to these failures in the forked repository.

To remedy this, I suggest we add the following condition to both GitHub Actions. This will prevent them from executing when the repository is a fork, thereby avoiding unnecessary failures:

# .github/workflows/storybook.yml
jobs:
  build:
    if: github.repository == 'EddieHubCommunity/LinkFree'
    runs-on: ubuntu-latest
    steps:
        # steps here...
 
  deploy:
    if: github.repository == 'EddieHubCommunity/LinkFree' && github.event_name != 'pull_request'
    # other properties here...
    steps:
      # steps here...
# .github/workflows/vercel.yml
jobs:
  deploy:
    if: github.repository == 'EddieHubCommunity/LinkFree'
    runs-on: ubuntu-latest
    steps:
        # steps here...

Upon triaging of this issue, I would be glad to implement these changes. Thanks!

Additional information

No response

weilincheng avatar May 12 '23 02:05 weilincheng

To reduce notifications, issues are locked until they are https://github.com/EddieHubCommunity/LinkFree/labels/%F0%9F%8F%81%20status%3A%20ready%20for%20dev and to be assigned. You can learn more in our contributing guide https://github.com/EddieHubCommunity/LinkFree/blob/main/CONTRIBUTING.md

github-actions[bot] avatar May 12 '23 02:05 github-actions[bot]

GitHub Actions are disabled by default when forking a repo, but it looks like some people enable them, most Actions should not run as will cause conflicts, especially from the Actions that generate files and new commits - so I think we should disable them all

eddiejaoude avatar May 12 '23 05:05 eddiejaoude

Thank you for raising the issue, I think it is a good idea, I have assigned it to you

eddiejaoude avatar May 12 '23 05:05 eddiejaoude

Thank you for raising the issue, I think it is a good idea, I have assigned it to you

Thanks, Eddie. After giving it more thought, I think it might be good for a new community member looking for their first task to tackle this. I'll go ahead and unassign myself for now. 😄

weilincheng avatar May 12 '23 06:05 weilincheng

Thank you for raising the issue, I think it is a good idea, I have assigned it to you

Thanks, Eddie. After giving it more thought, I think it might be good for a new community member looking for their first task to tackle this. I'll go ahead and unassign myself for now. 😄

Sure, great idea, thank you 👍

eddiejaoude avatar May 12 '23 06:05 eddiejaoude

Hello, I checked out the files and the changes needed, and I'd like to try it out as my first task!

poorvijn avatar May 12 '23 07:05 poorvijn

awesome @poorvijn I will assign it to you 👍 any questions let us know

eddiejaoude avatar May 12 '23 10:05 eddiejaoude

hello, I tried implementing the changes needed, and this is what I got:

storybook.yml:

storybookyaml

vercel.yml: vercelyaml

I tried to understand how I could fix them, but I couldn't get any further. Could you please suggest something?

poorvijn avatar May 14 '23 11:05 poorvijn

  1. maybe keep the if in the same location as before, just append the extra condition to it
  2. don't worry about the secrets.VERCEL_TOKEN error I get it also, it will run fine on Github Actions

eddiejaoude avatar May 14 '23 12:05 eddiejaoude

Hey, so I tried changing it as you mentioned, but it's still showing me the same error.

Here's how the storybook.yml file looks with the changes you mentioned:

storybookyamlerror

I also tried copying the code for deployment from the repo and then doing the changes again, but I'm afraid I'm getting the same error

poorvijn avatar May 14 '23 12:05 poorvijn

Can you create a draft pull request with your changes and I can see what I get locally - maybe the vscode plugin has a temporary issue (it happens)

eddiejaoude avatar May 14 '23 12:05 eddiejaoude

done!

poorvijn avatar May 14 '23 12:05 poorvijn

Thanks. I will edit your PR description to reference this issue.

Btw I don't get any warnings, the changes look fine to me and are happy in VScode

eddiejaoude avatar May 14 '23 15:05 eddiejaoude

awesome, I'll check my plugins on VScode. Thank you !

poorvijn avatar May 14 '23 16:05 poorvijn