[Release] Stage to Main 11/04 #31
This file contains 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
name: Merged to Main | |
on: | |
# Triggered when a pull request is closed or merged into the main branch | |
pull_request: | |
branches: | |
- main | |
types: | |
- closed | |
# Allow manual triggering of the workflow with a PR number input | |
workflow_dispatch: | |
inputs: | |
pr_number: | |
description: "PR Number" | |
default: "200" | |
required: true | |
env: | |
# Slack webhook URL from secret | |
CC_RELEASE_SLACK_WH: ${{ secrets.CC_RELEASE_SLACK_WH }} | |
jobs: | |
send_release_notes: | |
runs-on: ubuntu-latest | |
environment: cc_pr_merge | |
# This condition ensures the job runs only when a pull request is merged or the workflow is manually triggered | |
if: ${{ (github.event_name != 'workflow_dispatch' && github.event.pull_request.merged) || github.event_name == 'workflow_dispatch' }} | |
steps: | |
# Step to check out the repository | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
# Step to install Octokit | |
- name: Install Octokit | |
run: npm i -D @octokit/rest | |
# Step to set PR_NUMBER environment variable from the pull request event | |
- name: Set PR Number from PR event | |
if: ${{ github.event_name != 'workflow_dispatch' }} | |
run: echo "PR_NUMBER=${{ github.event.pull_request.number }}" >> $GITHUB_ENV | |
# Step to set PR_NUMBER environment variable from the workflow dispatch input | |
- name: Set PR Number from Input | |
if: ${{ github.event_name == 'workflow_dispatch' }} | |
run: echo "PR_NUMBER=${{ github.event.inputs.pr_number }}" >> $GITHUB_ENV | |
# Step to send release notes to the cc-changelog Slack channel | |
- name: Sending Release Notes to cc-changelog slack channel | |
uses: actions/github-script@v7 | |
with: | |
script: | | |
const { sendReleaseNotes } = require('./.github/workflows/src/send-slack.js') | |
sendReleaseNotes(process.env.PR_NUMBER, process.env.CC_RELEASE_SLACK_WH) |