Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(ci): fixed release notification action; #6064

Merged
merged 39 commits into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
3f2f496
chore(ci): Add release-it script;
DigitalBrainJS Dec 10, 2022
1bfc41b
Merge branch 'chore/release-it' into v1.x
DigitalBrainJS Dec 10, 2022
acaf0f4
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Dec 15, 2022
8a5de86
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Dec 15, 2022
cff9271
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Dec 17, 2022
67afe20
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Dec 19, 2022
dc7b66d
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Dec 22, 2022
716eb59
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Dec 23, 2022
10216bf
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Dec 29, 2022
3b199f4
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Jan 7, 2023
f3d444f
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Jan 19, 2023
077c381
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Jan 26, 2023
f598657
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Jan 31, 2023
7bf5713
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Feb 5, 2023
81a8bd6
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Mar 8, 2023
f8bb158
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Apr 5, 2023
3f1c768
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Apr 18, 2023
a9b0418
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Apr 25, 2023
1a16f4e
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Apr 27, 2023
5e22e2f
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS May 10, 2023
b7c77b0
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Aug 25, 2023
2200038
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Aug 25, 2023
df38e0c
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Aug 26, 2023
878548a
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Aug 26, 2023
7a33bcd
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Aug 28, 2023
5cafdeb
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Sep 13, 2023
f0e6b28
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Sep 26, 2023
98371b0
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Sep 28, 2023
bee6e45
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Oct 4, 2023
c97df04
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Oct 26, 2023
62274b7
Merge branch 'v1.x' of https://github.com/axios/axios into v1.x
DigitalBrainJS Oct 28, 2023
9688411
chore(ci): added labeling and notification for published PRs;
DigitalBrainJS Nov 8, 2023
f767d94
Merge branch 'v1.x' into ci/notify-published-pr
DigitalBrainJS Nov 8, 2023
4c5d152
chore(ci): added labeling and notification for published PRs;
DigitalBrainJS Nov 8, 2023
f254bf5
Merge branch 'ci/notify-published-pr' of https://github.com/DigitalBr…
DigitalBrainJS Nov 8, 2023
f5ad603
Merge branch 'v1.x' of https://github.com/axios/axios into ci/notify-…
DigitalBrainJS Nov 8, 2023
c6e9b68
chore(ci): fixed release notification action;
DigitalBrainJS Nov 8, 2023
e62e632
chore(ci): fixed release notification action;
DigitalBrainJS Nov 8, 2023
affc317
Merge branch 'v1.x' of https://github.com/axios/axios into ci/notify-…
DigitalBrainJS Nov 8, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 3 additions & 3 deletions bin/GithubAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export default class GithubAPI {
return (await this.axios.post(`/issues/${issue}/comments`, {body})).data;
}

async getComments(issue, {desc = false, per_page= 100, page = 1}) {
async getComments(issue, {desc = false, per_page= 100, page = 1} = {}) {
return (await this.axios.get(`/issues/${issue}/comments`, {params: {direction: desc ? 'desc' : 'asc', per_page, page}})).data;
}

Expand All @@ -40,11 +40,11 @@ export default class GithubAPI {
}

async appendLabels(issue, labels) {
return (await this.axios.post(`issues/${issue}/labels`, {labels})).data;
return (await this.axios.post(`/issues/${issue}/labels`, {labels})).data;
}

async getUser(user) {
return (await this.axios.get(`users/${user}`)).data;
return (await githubAxios.get(`/users/${user}`)).data;
}

async isCollaborator(user) {
Expand Down
25 changes: 23 additions & 2 deletions bin/RepoBot.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,19 @@ import Handlebars from "handlebars";
import fs from "fs/promises";
import {colorize} from "./helpers/colorize.js";
import {getReleaseInfo} from "./contributors.js";
import path from "path";
import {fileURLToPath} from "url";

const __dirname = path.dirname(fileURLToPath(import.meta.url));

const NOTIFY_PR_TEMPLATE = path.resolve(__dirname, '../templates/pr_published.hbs');

const normalizeTag = (tag) => tag ? 'v' + tag.replace(/^v/, '') : '';

const GITHUB_BOT_LOGIN = 'github-actions[bot]';

const skipCollaboratorPRs = true;

class RepoBot {
constructor(options) {
const {
Expand All @@ -15,7 +25,7 @@ class RepoBot {
} = options || {};

this.templates = Object.assign({
published: '../templates/pr_published.hbs'
published: NOTIFY_PR_TEMPLATE
}, templates);

this.github = api || new GithubAPI(owner, repo);
Expand Down Expand Up @@ -53,7 +63,18 @@ class RepoBot {

await this.github.appendLabels(id, [tag]);

if (isBot || labels.find(({name}) => name === 'automated pr') || (await this.github.isCollaborator(login))) {
if (isBot || labels.find(({name}) => name === 'automated pr') || (skipCollaboratorPRs && await this.github.isCollaborator(login))) {
return false;
}

const comments = await this.github.getComments(id, {desc: true});

const comment = comments.find(
({body, user}) => user.login === GITHUB_BOT_LOGIN && body.indexOf('published in') >= 0
)

if (comment) {
console.log(colorize()`Release comment [${comment.html_url}] already exists in #${pr.id}`);
return false;
}

Expand Down
10 changes: 9 additions & 1 deletion bin/githubAxios.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,19 @@
import axios from '../index.js';
import {colorize} from "./helpers/colorize.js";

const {GITHUB_TOKEN} = process.env;

GITHUB_TOKEN ? console.log(`[GITHUB_TOKEN OK]`) : console.warn(`[GITHUB_TOKEN is not defined]`);

const defaultTransform = axios.defaults.transformRequest;

export default axios.create({
transformRequest: [defaultTransform[0], function (data) {
console.log(colorize()`[${this.method.toUpperCase()}] Request [${new URL(axios.getUri(this)).pathname}]`);
return data;
}],
baseURL: 'https://api.github.com/',
headers: {
Authorization: GITHUB_TOKEN ? `token ${GITHUB_TOKEN}` : null
}
})
});
2 changes: 1 addition & 1 deletion templates/pr_published.hbs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
Hello, @{{ author.login }}! This PR has been published in [{{ release.tag }}]({{ release.url }}) release. Thank you for your contribution ❤️!
Hi, @{{ author.login }}! This PR has been published in [{{ release.tag }}]({{ release.url }}) release. Thank you for your contribution ❤️!