Skip to content

Commit ff9baf7

Browse files
authored
Log release PR number (#5488)
1 parent a5d87bc commit ff9baf7

File tree

2 files changed

+100
-0
lines changed

2 files changed

+100
-0
lines changed

.github/workflows/release-log.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
name: Log Release PR
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- release
7+
- v8-releasebranch
8+
9+
jobs:
10+
release:
11+
name: Send PR number to tracker endpoint
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repo
15+
uses: actions/checkout@master
16+
17+
- name: Setup Node.js 14.x
18+
uses: actions/setup-node@master
19+
with:
20+
node-version: 14.x
21+
22+
- name: Get PR number and send to tracker.
23+
run: node scripts/ci/log-changesets.js

scripts/ci/log-changesets.js

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
/**
2+
* @license
3+
* Copyright 2021 Google LLC
4+
*
5+
* Licensed under the Apache License, Version 2.0 (the "License");
6+
* you may not use this file except in compliance with the License.
7+
* You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software
12+
* distributed under the License is distributed on an "AS IS" BASIS,
13+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
* See the License for the specific language governing permissions and
15+
* limitations under the License.
16+
*/
17+
18+
const https = require('https');
19+
20+
async function logChangesets() {
21+
if (!process.env.GITHUB_EVENT_PATH) {
22+
console.log(`Couldn't find PR event payload.`);
23+
return;
24+
}
25+
26+
const prPayload = require(process.env.GITHUB_EVENT_PATH);
27+
28+
if (prPayload.pull_request.title !== 'Version Packages') {
29+
console.log(`Title of PR is not 'Version Packages'. Not logging.`);
30+
return;
31+
}
32+
33+
// The PR's "Description" field.
34+
if (!prPayload.pull_request.body) {
35+
console.log(`Unable to find PR description.`);
36+
return;
37+
}
38+
const matches = prPayload.pull_request.body.match(/## firebase@([\d\.]+)/);
39+
const version = matches[1];
40+
41+
if (!version) {
42+
console.log(`Unable to extract Firebase version from PR description.`);
43+
return;
44+
}
45+
46+
const data = JSON.stringify({
47+
version,
48+
pr: prPayload.pull_request.number
49+
});
50+
51+
const options = {
52+
hostname: 'us-central1-feature-tracker-8ca2b.cloudfunctions.net',
53+
path: '/logChangesetPR',
54+
port: 443,
55+
method: 'POST',
56+
headers: {
57+
'Content-Type': 'application/json'
58+
}
59+
};
60+
61+
return new Promise((resolve, reject) => {
62+
console.log(`Logging PR ${data.pr} with version ${data.version}.`);
63+
const req = https.request(options, res => {
64+
res.on('data', d => {
65+
process.stdout.write(d);
66+
});
67+
res.on('end', resolve);
68+
});
69+
70+
req.on('error', error => reject(error));
71+
72+
req.write(data);
73+
req.end();
74+
});
75+
}
76+
77+
logChangesets();

0 commit comments

Comments
 (0)