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

[GT-151] - Action jobs should be disabled in non-upstream repos #229

Conversation

Sae126V
Copy link
Member

@Sae126V Sae126V commented Apr 5, 2023

The condition given to cron JOB helps us to NOT trigger the event in a fork branches. And, It will only trigger the CRON Job if it is DEV branch.

"Resolves #211"

@Sae126V Sae126V requested a review from a team as a code owner April 5, 2023 12:57
@gregcorbett
Copy link
Member

can you add "Resolves #211" to the original PR comment? That will link the GitHub PR to the GitHub issue.

From the issue, https://docs.github.com/en/actions/using-jobs/using-conditions-to-control-job-execution showed using the syntax jobs.<job_id>.if to prevent a job from running unless a condition is met (i.e. if: github.repository == 'octo-org/octo-repo-prod).

Does github.event.repository.fork mean the event that gets fired when someone forks a repository? Which wouldn't stop the job from running in forks?

I think both codeql-analysis.yml and build-pkgs.yml define what branches or tags the job should run on, so why is github.ref == 'refs/heads/dev' needed?

@Sae126V
Copy link
Member Author

Sae126V commented Apr 6, 2023

Done. I have added Resolves 211 in the PR description.

Regarding the github.event.repository.fork

  1. github.event =>The full event webhook payload. You can access individual properties of the event using this context. This object is identical to the webhook payload of the event that triggered the workflow run and is different for each event.

Now, When I came across this GitHub Event Types - GitHub Events API, it had a property called repository.

  1. github.event.repository => (Object) => This gives where the event occurred.

  2. This Repository (REST API) has a fork attribute(Which will be taken care of by GitHub and return Boolean Value). fork helps us to see if the repo is forked or the original repo.

In short, github.event.repository.fork can tell us whether event happened in a forked branch or NOT.

And you are right @gregcorbett github.ref == 'refs/heads/dev is not needed. It just there as an additional check. I will remove that now.

@gregcorbett
Copy link
Member

gregcorbett commented Apr 6, 2023

In short, github.event.repository.fork can tell us if it is a forked branch or NOT.

ah okay. Should the if be moved into the job part of the yaml file - as opposed to the on part?

@Sae126V Sae126V force-pushed the GT-151-Events-should-be-disabled-in-non-upstream branch from 8e75437 to 1ba329b Compare April 11, 2023 07:42
@Sae126V Sae126V changed the title [GT-151] - Action jobs should be disabled in non-upstream branches [GT-151] - Action jobs should be disabled in non-upstream repos Apr 17, 2023
@gregcorbett
Copy link
Member

LGTM, can you squash the commits down into a single commit?

@Sae126V Sae126V force-pushed the GT-151-Events-should-be-disabled-in-non-upstream branch 2 times, most recently from 76b4fbc to 0ebd347 Compare May 9, 2023 07:48
@Sae126V Sae126V force-pushed the GT-151-Events-should-be-disabled-in-non-upstream branch from 387f69c to 2d91461 Compare May 9, 2023 07:52
@Sae126V
Copy link
Member Author

Sae126V commented May 9, 2023

Applied rebase on #229.

Copy link
Member

@gregcorbett gregcorbett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@tofu-rocketry tofu-rocketry added this to the 3.3.0 milestone Jun 12, 2023
@tofu-rocketry tofu-rocketry merged commit a197ad8 into apel:dev Jun 12, 2023
@tofu-rocketry
Copy link
Member

@Sae126V As this is merged (through a rebase) , can you delete your branch in GitHub now?

@Sae126V Sae126V deleted the GT-151-Events-should-be-disabled-in-non-upstream branch June 29, 2023 09:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

GT-151 Check for any Actions jobs that should be disabled in non-upstream repos
3 participants