-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAddRebaseInstructionsOnPROpen.yml
More file actions
58 lines (47 loc) · 1.85 KB
/
AddRebaseInstructionsOnPROpen.yml
File metadata and controls
58 lines (47 loc) · 1.85 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
# Copyright (c) LieberLieber GmbH & Robert Bosch GmbH
# 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/.
name: Add Rebase Instructions on PR Open
on:
pull_request:
types: [opened]
permissions:
pull-requests: write
jobs:
add_instructions:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Add rebase instructions to PR body
uses: actions/github-script@v8
with:
script: |
const fs = require('fs');
const path = require('path');
// Read instructions from file
const instructionsFile = path.join(process.env.GITHUB_WORKSPACE, '.github/pr-instructions.md');
let instructions = '';
if (fs.existsSync(instructionsFile)) {
instructions = fs.readFileSync(instructionsFile, 'utf8');
console.log('Read instructions from file');
} else {
console.log('Instructions file not found, skipping AppendBody');
return;
}
// Get current PR
const pr = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number
});
// Append instructions to PR body
const newBody = (pr.data.body || '') + instructions;
// Update PR with new body
await github.rest.pulls.update({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.issue.number,
body: newBody
});
console.log('Successfully updated PR body with instructions');