[MAIN][STRATCONN-6153] : [DV360] added feature flag for first party dv360 destination for upgrade version from v3 to v4 #89
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This workflow labels PRs based on the files that were changed and also assign a reviewer based on team. It uses a custom script to this | |
# instead of actions/labeler as few of the tags are more than just file changes. | |
name: Configure PR | |
on: | |
pull_request_target: | |
types: [opened, synchronize, reopened, ready_for_review] | |
jobs: | |
configure-pr: | |
runs-on: ubuntu-22.04 | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
persist-credentials: false | |
- name: Compute Labels | |
id: compute-labels | |
uses: actions/github-script@v7 | |
with: | |
# Required for the script to access team membership information. | |
# Scope: members:read and contentes:read permission on the organization. | |
github-token: ${{ secrets.GH_PAT_MEMBER_AND_PULL_REQUEST_READONLY }} | |
script: | | |
const script = require('./scripts/github-action/compute-labels.js') | |
await script({github, context, core}) | |
# Separating apply labels to separate step to avoid using PAT token auth. | |
- name: Apply Labels | |
uses: actions/github-script@v7 | |
env: | |
labelsToAdd: '${{ steps.compute-labels.outputs.add }}' | |
labelsToRemove: '${{ steps.compute-labels.outputs.remove }}' | |
with: | |
script: | | |
const { labelsToAdd, labelsToRemove, DRY_RUN } = process.env | |
if(Boolean(DRY_RUN)){ | |
core.info(`Would have added labels: ${labelsToAdd}`) | |
core.info(`Would have removed labels: ${labelsToRemove}`) | |
return | |
} | |
if(labelsToAdd.length > 0) { | |
await github.rest.issues.addLabels({ | |
issue_number: context.payload.pull_request.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
labels: labelsToAdd.split(',') | |
}); | |
} | |
if(labelsToRemove.length > 0) { | |
const requests = labelsToRemove.split(',').map(label => { | |
return github.rest.issues.removeLabel({ | |
issue_number: context.payload.pull_request.number, | |
name: label, | |
owner: context.repo.owner, | |
repo: context.repo.repo | |
}); | |
}); | |
await Promise.all(requests); | |
} | |
- name: Comment for mapping-kit changes | |
uses: actions/github-script@v7 | |
env: | |
labelsToAdd: '${{ steps.compute-labels.outputs.add }}' | |
labelsToRemove: '${{ steps.compute-labels.outputs.remove }}' | |
with: | |
script: | | |
const { labelsToAdd, labelsToRemove, DRY_RUN } = process.env | |
const shouldAddComment = labelsToAdd.length > 0 && labelsToAdd.split(",").some(x=>x.includes("mappingkit")) | |
const shouldRemoveComment = labelsToRemove.length > 0 && labelsToRemove.split(",").some(x=>x.includes("mappingkit")) | |
// Get the list of comments on the PR | |
const response = await github.rest.issues.listComments({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo | |
}) | |
const mappingKitComment = response.data.find(comment => comment.body.includes('mapping-kit go')) | |
if(shouldAddComment){ | |
if (mappingKitComment) { | |
console.log('Already commented on this PR') | |
return | |
} | |
// Add comment to the PR | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `This PR makes changes to mapping-kit. Please ensure that the changes are reflected in the [mapping-kit go](https://github.com/segmentio/mapping-kit) library as well and link the PR in description.` | |
}) | |
} | |
if(shouldRemoveComment) { | |
if (!mappingKitComment) { | |
console.log('No mapping-kit comment to remove') | |
return | |
} | |
// Remove comment from the PR | |
await github.rest.issues.deleteComment({ | |
comment_id: mappingKitComment.id, | |
owner: context.repo.owner, | |
repo: context.repo.repo | |
}) | |
} | |
- name: Get Reviewers | |
if: github.event.action == 'ready_for_review' || (github.event.action == 'opened' && !github.event.pull_request.draft) | |
id: get-reviewers | |
uses: actions/github-script@v7 | |
env: | |
labelsToAdd: '${{ steps.compute-labels.outputs.add }}' | |
with: | |
github-token: ${{ secrets.GH_PAT_MEMBER_AND_PULL_REQUEST_READONLY }} | |
script: | | |
const script = require('./scripts/github-action/get-reviewers.js') | |
await script({github, context, core}) | |
- name: Assign Reviewers | |
if: (github.event.action == 'ready_for_review' || (github.event.action == 'opened' && !github.event.pull_request.draft)) && steps.get-reviewers.outputs.skip != 'true' | |
uses: actions/github-script@v7 | |
env: | |
REVIEWERS: '${{ steps.get-reviewers.outputs.reviewers }}' | |
TEAM: '${{ steps.get-reviewers.outputs.team }}' | |
with: | |
script: | | |
const script = require('./scripts/github-action/assign-reviewer.js') | |
await script({github, context, core}) | |
- name: Log Skip Reviewer Assignment Reason | |
if: (github.event.action == 'ready_for_review' || (github.event.action == 'opened' && !github.event.pull_request.draft)) && steps.get-reviewers.outputs.skip == 'true' | |
run: echo "Skipping reviewer assignment - ${{ steps.get-reviewers.outputs.reason }}" |