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

Read pull_request and pull_request_target event info from GHA #1473

Merged
merged 1 commit into from
Oct 2, 2024

Conversation

juan-fernandez
Copy link
Contributor

What and why?

GitHub does not run workflows in the head of the branch about to be merged whenever the workflow is triggered through pull_request or pull_request_target events. It runs them in a merge commit. This is the one that we add to git.commit.sha. This is sometimes confusing because this commit does not exist in the history of the branch. What we did:

  • Notice when this happens
  • When it does, add a new set of tags:
    • git.commit.head_sha, which is the head SHA of the feature branch (branch to be merged).
    • git.pull_request.base_branch_sha, which is the head SHA of the base branch (branch you're merging into)
    • git.pull_request.base_branch, which is the name of the base branch

How?

Detect if we're in a pull_request or pull_request_target event by checking GITHUB_BASE_REF, and if we are, attempt to read the event.json payload made available by GitHub in GITHUB_EVENT_PATH.

Review checklist

  • Feature or bugfix MUST have appropriate tests (unit, integration)

@juan-fernandez juan-fernandez added the ci-visibility Related to [junit, gate, metric, tag, trace, dora, deployment] label Oct 2, 2024
@juan-fernandez juan-fernandez marked this pull request as ready for review October 2, 2024 10:49
@juan-fernandez juan-fernandez requested review from a team as code owners October 2, 2024 10:49
@datadog-datadog-prod-us1
Copy link

Datadog Report

Branch report: juan-fernandez/add-extra-tags-pull-request
Commit report: e98ab98
Test service: datadog-ci-tests

✅ 0 Failed, 8424 Passed, 0 Skipped, 3m 53.76s Total Time

Copy link
Contributor

@Drarig29 Drarig29 left a comment

Choose a reason for hiding this comment

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

The changed helpers look good to me (from Synthetics CT)

@juan-fernandez juan-fernandez merged commit 53b1ae4 into master Oct 2, 2024
19 checks passed
@juan-fernandez juan-fernandez deleted the juan-fernandez/add-extra-tags-pull-request branch October 2, 2024 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ci-visibility Related to [junit, gate, metric, tag, trace, dora, deployment]
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants