-
Notifications
You must be signed in to change notification settings - Fork 48
54 lines (46 loc) · 1.89 KB
/
merged-to-main.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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)