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

gh actions: issues workflow: disable job on forked PR's OR it's an issue #385

Merged
merged 2 commits into from
Jan 15, 2024

Conversation

eguzki
Copy link
Contributor

@eguzki eguzki commented Dec 19, 2023

When the feature branch is in the Kuadrant/kuadrant-operator repo the github action context looks like this:

 "github.repository"  -> Kuadrant/kuadrant-operator
 "github.event.pull_request.head.repo.full_name" -> Kuadrant/kuadrant-operator

when the feature brnach is in another repo (forked one) and opens PR in this repo, the context looks like this:

"github.repository" -> Kuadrant/kuadrant-operator
"github.event.pull_request.head.repo.full_name" -> ilargitxiki/kuadrant-operator

When we want to disable job on PR's coming from forked repos to prevent it from failing (because there is no access to secrets), that is the cleanest way so far.

jobs:
  job_id:
    if: github.event.pull_request.head.repo.full_name == github.repository

Issues workflow will also be run when an issue is being opened.

Note: for some unknown reason, when issues are opened, not matter internal or external collaborator, the ADD_ISSUES_TOKEN secret is available and the issue is being added to the project

Tested:

  • External user creates issue ✔️
  • Internal collaborator creates issue ✔️
  • PR created by internal collaborator ✔️
  • PR from forked repo ❎ (not being run, and the workflow succeeds)

Copy link

codecov bot commented Dec 19, 2023

Codecov Report

Merging #385 (bb6ed39) into main (1bd09bc) will decrease coverage by 0.66%.
Report is 1 commits behind head on main.
The diff coverage is n/a.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #385      +/-   ##
==========================================
- Coverage   65.29%   64.63%   -0.66%     
==========================================
  Files          35       35              
  Lines        3795     3795              
==========================================
- Hits         2478     2453      -25     
- Misses       1125     1145      +20     
- Partials      192      197       +5     
Flag Coverage Δ
integration 69.64% <ø> (-1.24%) ⬇️
unit 58.90% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
api/v1beta1 (u) ∅ <ø> (∅)
pkg/common (u) 76.92% <ø> (ø)
pkg/istio (u) 37.11% <ø> (ø)
pkg/log (u) 31.81% <ø> (ø)
pkg/reconcilers (u) 33.21% <ø> (ø)
pkg/rlptools (u) 56.46% <ø> (ø)
controllers (i) 69.64% <ø> (-1.24%) ⬇️

see 4 files with indirect coverage changes

@eguzki eguzki force-pushed the gh-actions-disabled-from-forks branch from f452f60 to 2f0da31 Compare December 19, 2023 09:52
@eguzki eguzki changed the title [do not merge] get gh actions metadata gh actions: disable job on forked PR's Dec 19, 2023
@eguzki eguzki marked this pull request as ready for review December 19, 2023 10:00
@eguzki eguzki requested a review from a team as a code owner December 19, 2023 10:00
Copy link
Contributor

@guicassolato guicassolato left a comment

Choose a reason for hiding this comment

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

Makes sense to me.

@eguzki
Copy link
Contributor Author

eguzki commented Dec 19, 2023

integration tests failing 😢

@eguzki eguzki changed the title gh actions: disable job on forked PR's gh actions: disable job on forked PR's OR it's an issue Dec 19, 2023
@eguzki eguzki changed the title gh actions: disable job on forked PR's OR it's an issue gh actions: issues workflow: disable job on forked PR's OR it's an issue Dec 19, 2023
@eguzki
Copy link
Contributor Author

eguzki commented Dec 19, 2023

Another approach would be to have two workflows, one for issues opened and the other for PR's not coming from forked repos

@alexsnaps alexsnaps merged commit 771147d into main Jan 15, 2024
21 of 22 checks passed
@alexsnaps alexsnaps deleted the gh-actions-disabled-from-forks branch January 15, 2024 12:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants