Skip to content

TEST | [Release] test_branch to test_branch #10

TEST | [Release] test_branch to test_branch

TEST | [Release] test_branch to test_branch #10

name: Merged to Main
on:
# Triggered when a pull request is closed and merged into the main branch
pull_request:
branches:
- test-ghwf-target
types:
- closed
# Manually triggered workflow with inputs for title and body
workflow_dispatch:
inputs:
pr_number:
description: 'PR Number'
default: '200'
required: true
title:
description: 'Title for the PR'
default: 'TEST | [Release] Stage to Main'
required: true
body:
type: string
description: 'Description for the PR'
default: 'TEST | Description of the *PR*'
required: true
jobs:
# Job to handle merged pull requests
merged_to_main:
runs-on: ubuntu-latest
environment: cc_pr_merge
# Run the job when a pull request is merged into main and not triggered manually
# #TODO: add github.event.pull_request.merged this condition before the stage PR
if: ${{ github.event_name != 'workflow_dispatch' }}
env:
# Environment variable to store pull request details
EVENT_PR: ${{ toJson(github.event.pull_request) }}
CC_RELEASE_SLACK_WH: ${{ secrets.CC_RELEASE_SLACK_WH }}
steps:
# Checkout repository action
- name: Checkout repository
uses: actions/checkout@v4
# Sending release notes to cc-changelog 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.EVENT_PR,process.env.CC_RELEASE_SLACK_WH)
# Job to handle manually triggered workflow_dispatch events
workflow_dispatch_event:
runs-on: ubuntu-latest
environment: cc_pr_merge
# Run the job when the workflow is manually triggered
if: ${{ github.event_name == 'workflow_dispatch' }}
steps:
# Checkout repository action
- name: Check repository
uses: actions/checkout@v4
# Sending release notes to cc-changelog channel
- name: Sending Release Notes to cc-changelog slack channel
uses: actions/github-script@v7
# Set environment variables for repository URL, PR number,PR title, and PR description
env:
REPO_URL: ${{github.event.repository.html_url}}
PR_NUMBER: ${{github.event.inputs.pr_number}}
PR_TITLE: ${{github.event.inputs.title}}
PR_DESC: ${{github.event.inputs.body}}
CC_RELEASE_SLACK_WH: ${{ secrets.CC_RELEASE_SLACK_WH }}
with:
script: |
const {sendReleaseNotes} = require('./.github/workflows/src/send-slack.js')
sendReleaseNotes(JSON.stringify({
number:process.env.PR_NUMBER,
html_url:process.env.REPO_URL+"/pull/"+process.env.PR_NUMBER,
title:process.env.PR_TITLE,
body:process.env.PR_DESC
}),process.env.CC_RELEASE_SLACK_WH)