-
Notifications
You must be signed in to change notification settings - Fork 73
45 lines (42 loc) · 1.65 KB
/
on-label-added-for-pr.yml
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
# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at https://mozilla.org/MPL/2.0/.
#
# OpenCRVS is also distributed under the terms of the Civil Registration
# & Healthcare Disclaimer located at http://opencrvs.org/license.
#
# Copyright (C) The OpenCRVS Authors located at https://github.com/opencrvs/opencrvs-core/blob/master/AUTHORS.
name: Listen for labels added to PRs
on:
pull_request:
types: [labeled]
jobs:
dispatch-deploy:
runs-on: ubuntu-latest
steps:
- name: Check if added label is "🚀 Ready to deploy"
id: label_check
run: |
added_label=$(jq -r '.label.name' "$GITHUB_EVENT_PATH")
if [[ "$added_label" != "🚀 Ready to deploy" ]]; then
echo "Label not found or incorrect, skipping dispatch."
exit 1
fi
echo "Correct label added, dispatching deploy workflow."
- name: Trigger Deploy Workflow
if: steps.label_check.outcome == 'success'
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prNumber = context.payload.pull_request.number;
const result = await github.rest.actions.createWorkflowDispatch({
owner: context.repo.owner,
repo: context.repo.repo,
workflow_id: 'deploy-to-feature-environment.yml',
ref: context.payload.pull_request.head.ref,
inputs: {
pr_number: prNumber.toString(),
}
});
console.log(result);