2024-10-28 09:34:10 +00:00
|
|
|
name: New CFE/PRR workflow notifications
|
2024-10-07 20:41:03 +00:00
|
|
|
on:
|
|
|
|
issues:
|
|
|
|
types: [labeled]
|
|
|
|
|
2024-10-28 07:31:41 +00:00
|
|
|
permissions: {}
|
2024-10-07 20:41:03 +00:00
|
|
|
|
|
|
|
jobs:
|
2024-10-28 07:31:41 +00:00
|
|
|
prep:
|
2024-10-30 07:54:23 +00:00
|
|
|
if: github.event.label.name == 'code freeze exception' || github.event.label.name == 'point release request' || github.event.label.name == 'Approved' || github.event.label.name == 'Rejected'
|
2024-10-28 07:31:41 +00:00
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
outputs:
|
|
|
|
release_number: ${{ steps.extract-release.outputs.RELEASE_NUMBER }}
|
|
|
|
steps:
|
|
|
|
- name: Extract Release Number from Issue Body
|
|
|
|
id: extract-release
|
|
|
|
uses: actions/github-script@v7
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const body = context.payload.issue.body; // Accessing the issue body directly from the context
|
|
|
|
|
|
|
|
// Regular expression to match the release number after the specific question
|
|
|
|
const releaseRegex = /Which release does this request apply to\?.*?\n([0-9]+\.[0-9]+)/s;
|
|
|
|
|
|
|
|
// Match the body against the regex
|
|
|
|
const match = body.match(releaseRegex);
|
|
|
|
|
|
|
|
// Check if a valid release number was found
|
|
|
|
if (match && match[1]) {
|
|
|
|
const releaseNumber = match[1];
|
|
|
|
|
|
|
|
// Log the release number and set it as a GitHub output
|
|
|
|
console.log(`Valid release number: ${releaseNumber}`);
|
|
|
|
core.setOutput('RELEASE_NUMBER', releaseNumber);
|
|
|
|
} else {
|
|
|
|
// If no valid release number is found, fail the step
|
|
|
|
core.setFailed("No valid release number found after the 'Which release does this request apply to?' section. Aborting.");
|
|
|
|
}
|
|
|
|
|
2024-10-30 07:54:23 +00:00
|
|
|
apply-milestone:
|
|
|
|
if: github.event.label.name == 'code freeze exception' || github.event.label.name == 'point release request' || github.event.label.name == 'Approved' || github.event.label.name == 'Rejected'
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
permissions:
|
|
|
|
issues: write
|
|
|
|
needs:
|
|
|
|
- prep
|
|
|
|
steps:
|
|
|
|
- name: Apply Milestone to the Issue
|
|
|
|
env:
|
|
|
|
MILESTONE: ${{ needs.prep.outputs.release_number }}.0
|
|
|
|
ISSUE_URL: ${{ github.event.issue.html_url }}
|
|
|
|
GH_TOKEN: ${{ github.token }}
|
|
|
|
run: |
|
|
|
|
echo "Applying milestone: $MILESTONE"
|
|
|
|
gh issue edit "$ISSUE_URL" --milestone "$MILESTONE"
|
|
|
|
|
2024-10-07 20:41:03 +00:00
|
|
|
cfe-created:
|
2024-10-28 09:34:10 +00:00
|
|
|
if: github.event.label.name == 'code freeze exception' || github.event.label.name == 'point release request'
|
2024-10-07 20:41:03 +00:00
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
2024-10-28 09:34:10 +00:00
|
|
|
- name: Set Slack Message
|
|
|
|
id: set-message
|
|
|
|
uses: actions/github-script@v7
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const event = context.payload;
|
|
|
|
const labelName = event.label?.name;
|
|
|
|
const issueTitle = event.issue.title;
|
|
|
|
const issueUrl = event.issue.html_url;
|
|
|
|
|
|
|
|
let message = '';
|
|
|
|
|
|
|
|
// Determine the type of message based on the label name
|
|
|
|
if (labelName === 'code freeze exception') {
|
|
|
|
message = `:arrow_right: New CFE request: ${issueTitle} ${issueUrl}`;
|
|
|
|
} else {
|
|
|
|
message = `:arrow_right: New PRR request: ${issueTitle} ${issueUrl}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Set the message as a core output
|
|
|
|
core.setOutput('SLACK_MESSAGE', message);
|
|
|
|
|
2024-10-07 20:41:03 +00:00
|
|
|
- name: Notify Slack
|
|
|
|
uses: archive/github-actions-slack@v2.0.0
|
|
|
|
id: notify
|
|
|
|
with:
|
|
|
|
slack-bot-user-oauth-access-token: ${{ secrets.CODE_FREEZE_BOT_TOKEN }}
|
|
|
|
slack-channel: ${{ secrets.WOO_RELEASE_SLACK_CHANNEL }}
|
2024-10-28 09:34:10 +00:00
|
|
|
slack-text: ${{ steps.set-message.outputs.SLACK_MESSAGE }}
|
2024-10-07 20:41:03 +00:00
|
|
|
slack-optional-unfurl_links: false
|
|
|
|
slack-optional-unfurl_media: false
|
|
|
|
continue-on-error: true
|
|
|
|
|
2024-10-28 09:34:10 +00:00
|
|
|
request-approved:
|
|
|
|
if: ${{ github.event.label.name == 'Approved' }}
|
2024-10-07 20:41:03 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2024-10-28 07:31:41 +00:00
|
|
|
permissions:
|
|
|
|
pull-requests: write
|
|
|
|
issues: write
|
2024-10-07 20:41:03 +00:00
|
|
|
steps:
|
2024-10-28 07:31:41 +00:00
|
|
|
- name: Extract PR number from issue body
|
2024-10-07 20:41:03 +00:00
|
|
|
id: extract-pr
|
2024-10-28 07:31:41 +00:00
|
|
|
uses: actions/github-script@v7
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const body = context.payload.issue.body;
|
2024-10-07 20:41:03 +00:00
|
|
|
|
2024-10-28 07:31:41 +00:00
|
|
|
// Regular expression to match the PR link that follows the specific question
|
|
|
|
const prRegex = /Which PR needs to be included\?.*?\n(https:\/\/github\.com\/[a-zA-Z0-9_\-]+\/[a-zA-Z0-9_\-]+\/pull\/([0-9]+))/s;
|
|
|
|
|
|
|
|
// Match the body against the regex
|
|
|
|
const match = body.match(prRegex);
|
|
|
|
|
|
|
|
// Check if a valid PR number was found
|
|
|
|
if (match && match[2]) {
|
|
|
|
const prNumber = match[2];
|
|
|
|
|
|
|
|
// Log the PR number and set it as a GitHub output
|
|
|
|
console.log(`Valid PR number: ${prNumber}`);
|
|
|
|
core.setOutput('PR_NUMBER', prNumber);
|
|
|
|
} else {
|
|
|
|
// If no valid PR number is found, fail the step
|
|
|
|
core.setFailed("No valid PR found after the 'Which PR' section. Aborting.");
|
|
|
|
}
|
2024-10-07 20:41:03 +00:00
|
|
|
|
|
|
|
- name: Add label 'cherry pick to trunk' to PR
|
|
|
|
env:
|
2024-10-28 07:31:41 +00:00
|
|
|
OWNER: ${{ github.event.repository.owner.login }}
|
|
|
|
REPO: ${{ github.event.repository.name }}
|
|
|
|
PR_NUMBER: ${{ steps.extract-pr.outputs.PR_NUMBER }}
|
2024-10-07 20:41:03 +00:00
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: |
|
2024-10-28 09:34:10 +00:00
|
|
|
gh pr edit $PR_NUMBER --add-label "cherry pick to trunk" --repo "$OWNER/$REPO"
|
|
|
|
|
|
|
|
- name: Add label 'cherry pick to frozen release' to PR
|
|
|
|
if: contains(github.event.issue.labels.*.name, 'point release request')
|
|
|
|
env:
|
|
|
|
OWNER: ${{ github.event.repository.owner.login }}
|
|
|
|
REPO: ${{ github.event.repository.name }}
|
|
|
|
PR_NUMBER: ${{ steps.extract-pr.outputs.PR_NUMBER }}
|
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
|
|
run: |
|
|
|
|
gh pr edit $PR_NUMBER --add-label "cherry pick to frozen release" --repo "$OWNER/$REPO"
|
2024-10-07 20:41:03 +00:00
|
|
|
|
2024-10-28 07:31:41 +00:00
|
|
|
- name: Comment issue has been approved
|
2024-10-07 20:41:03 +00:00
|
|
|
env:
|
2024-10-28 07:31:41 +00:00
|
|
|
ISSUE_URL: ${{ github.event.issue.html_url }}
|
2024-10-07 20:41:03 +00:00
|
|
|
GH_TOKEN: ${{ github.token }}
|
2024-10-28 07:31:41 +00:00
|
|
|
run: |
|
|
|
|
gh issue comment "$ISSUE_URL" --body "This request has been approved. Please merge the PR to release branch."
|
2024-10-07 20:41:03 +00:00
|
|
|
|
2024-10-28 09:34:10 +00:00
|
|
|
- name: Set Slack Message
|
|
|
|
id: set-message
|
|
|
|
uses: actions/github-script@v7
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const event = context.payload; // Accessing the event directly from the context
|
|
|
|
const labelName = event.label?.name;
|
|
|
|
const issueTitle = event.issue.title;
|
|
|
|
const issueUrl = event.issue.html_url;
|
|
|
|
|
|
|
|
let message = '';
|
|
|
|
|
|
|
|
if (labelName === 'code freeze exception') {
|
|
|
|
message = `:white_check_mark: CFE request approved: ${issueTitle} ${issueUrl}`;
|
|
|
|
} else {
|
|
|
|
message = `:white_check_mark: PRR request approved: ${issueTitle} ${issueUrl}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
core.setOutput('SLACK_MESSAGE', message);
|
|
|
|
|
2024-10-07 20:41:03 +00:00
|
|
|
- name: Notify Slack
|
|
|
|
uses: archive/github-actions-slack@v2.0.0
|
|
|
|
id: notify
|
|
|
|
with:
|
|
|
|
slack-bot-user-oauth-access-token: ${{ secrets.CODE_FREEZE_BOT_TOKEN }}
|
|
|
|
slack-channel: ${{ secrets.WOO_CORE_RELESES_DAILY_SLACK_CHANNEL }}
|
2024-10-28 09:34:10 +00:00
|
|
|
slack-text: ${{ steps.set-message.outputs.SLACK_MESSAGE }}
|
2024-10-07 20:41:03 +00:00
|
|
|
slack-optional-unfurl_links: false
|
|
|
|
slack-optional-unfurl_media: false
|
|
|
|
continue-on-error: true
|
|
|
|
|
2024-10-28 09:34:10 +00:00
|
|
|
request-rejected:
|
|
|
|
if: ${{ github.event.label.name == 'Rejected' }}
|
2024-10-07 20:41:03 +00:00
|
|
|
runs-on: ubuntu-20.04
|
2024-10-28 07:31:41 +00:00
|
|
|
permissions:
|
|
|
|
issues: write
|
2024-10-07 20:41:03 +00:00
|
|
|
steps:
|
2024-10-28 09:34:10 +00:00
|
|
|
- name: Close the request
|
2024-10-07 20:41:03 +00:00
|
|
|
env:
|
2024-10-28 07:31:41 +00:00
|
|
|
ISSUE_URL: ${{ github.event.issue.html_url }}
|
2024-10-07 20:41:03 +00:00
|
|
|
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
2024-10-28 07:31:41 +00:00
|
|
|
run: |
|
2024-10-29 18:14:20 +00:00
|
|
|
gh issue close "$ISSUE_URL" --comment "Closing issue as the request is rejected - $ISSUE_URL. Please switch the base to trunk and merge."
|
2024-10-28 09:34:10 +00:00
|
|
|
|
|
|
|
- name: Set Slack Message
|
|
|
|
id: set-message
|
|
|
|
uses: actions/github-script@v7
|
|
|
|
with:
|
|
|
|
script: |
|
|
|
|
const event = context.payload;
|
|
|
|
const labelName = event.label?.name;
|
|
|
|
const issueTitle = event.issue.title;
|
|
|
|
const issueUrl = event.issue.html_url;
|
|
|
|
|
|
|
|
let message = '';
|
|
|
|
|
|
|
|
if (labelName === 'code freeze exception') {
|
|
|
|
message = `:x: CFE request rejected: ${issueTitle} ${issueUrl}`;
|
|
|
|
} else {
|
|
|
|
message = `:x: PRR request rejected: ${issueTitle} ${issueUrl}`;
|
|
|
|
}
|
|
|
|
|
|
|
|
core.setOutput('SLACK_MESSAGE', message);
|
|
|
|
|
2024-10-07 20:41:03 +00:00
|
|
|
|
|
|
|
- name: Notify Slack
|
|
|
|
uses: archive/github-actions-slack@v2.0.0
|
|
|
|
id: notify
|
|
|
|
with:
|
|
|
|
slack-bot-user-oauth-access-token: ${{ secrets.CODE_FREEZE_BOT_TOKEN }}
|
|
|
|
slack-channel: ${{ secrets.WOO_CORE_RELESES_DAILY_SLACK_CHANNEL }}
|
2024-10-28 09:34:10 +00:00
|
|
|
slack-text: ${{ steps.set-message.outputs.SLACK_MESSAGE }}
|
2024-10-07 20:41:03 +00:00
|
|
|
slack-optional-unfurl_links: false
|
|
|
|
slack-optional-unfurl_media: false
|
2024-10-28 07:31:41 +00:00
|
|
|
continue-on-error: true
|