-
Notifications
You must be signed in to change notification settings - Fork 0
64 lines (58 loc) · 2.03 KB
/
Copy pathon-pr-label.yml
File metadata and controls
64 lines (58 loc) · 2.03 KB
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
55
56
57
58
59
60
61
62
63
64
# Workflow Name: On PR label
#
# Owner: Digdir Platform team / Digdir development teams
#
# Purpose:
# This workflow is responsible for appending an internal commit string to the
# title of a pull request when the 'internal' label is added. This could be
# expanded in the future to include other actions based on different labels,
# but for now it serves the specific purpose of marking PRs as internal by
# appending a predefined string to the PR title. PRs updated using this
# workflow will be ignored when generating public release notes.
#
# Flow:
# 1. When a label is added to a PR, check if the label is 'internal'
# 2. If the label is 'internal', append the internal commit string to the PR
# title if it is not already present
#
# Trigger:
# Triggered by workflow calls (workflow_call)
#
# Inputs:
# None
#
# Outputs:
# None
#
name: On PR label
permissions: {}
on:
workflow_call:
env:
INTERNAL_COMMIT_STRING: "(INTERNAL-COMMIT)"
jobs:
append-internal-commit-string-to-title:
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: github.event.label.name == 'internal'
steps:
- name: Append ${{ env.INTERNAL_COMMIT_STRING }} to PR title
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # pin@v9.0.0
with:
github-token: ${{ github.token }}
script: |
const { pull_request } = context.payload;
const commitString = process.env.INTERNAL_COMMIT_STRING;
const newTitle = `${pull_request.title} ${commitString}`;
if (!pull_request.title.includes(commitString)) {
const response = await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: pull_request.number,
title: newTitle,
});
core.info(`PR title updated to ${response.data.title}`);
} else {
core.info(`PR title already contains ${commitString}`);
}