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

Added notification on error #9

Merged
merged 6 commits into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/up-to-date.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

jobs:
updatePullRequests:
name: Keep PRs up to date
runs-on: ubuntu-latest
steps:
- name: Update all the PRs
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ on:

jobs:
updatePullRequests:
name: Keep PRs up to date
runs-on: ubuntu-latest
steps:
- name: Update all the PRs
Expand Down
2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ outputs:

runs:
using: 'docker'
image: 'docker://ghcr.io/paritytech/up-to-date-action/action:0.1.0'
image: 'docker://ghcr.io/paritytech/up-to-date-action/action:0.2.0'
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "up-to-date-action",
"version": "0.1.0",
"version": "0.2.0",
"description": "Keep all your PRs up to date when a new commit is pushed to the main branch",
"main": "src/index.ts",
"scripts": {
Expand Down
8 changes: 8 additions & 0 deletions src/github/pullRequest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,12 @@ export class PullRequestApi {

return data.message;
}

async comment(number: number, msg: string): Promise<void> {
await this.api.rest.issues.createComment({
...this.repo,
issue_number: number,
body: msg,
});
}
}
8 changes: 8 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const logger = generateCoreLogger();
const action = async () => {
const token = getInput("GITHUB_TOKEN", { required: true });
const repoInfo = getRepo(context);
const actionUrl = `${context.serverUrl}/${repoInfo.owner}/${repoInfo.repo}/actions/runs/${context.runId}`;
const requireAutoMerge: boolean =
getInput("REQUIRE_AUTO_MERGE", { required: false }) !== "false";
const api = new PullRequestApi(getOctokit(token), repoInfo, logger);
Expand Down Expand Up @@ -54,6 +55,13 @@ const action = async () => {
} catch (error) {
logger.error(error as string | Error);
rows.push([repoTxt, title, "Fail ❌"]);
await api.comment(
number,
"# Failed to update PR ❌\n\n" +
"There was an error while trying to keep this PR `up-to-date`\n\n" +
"You may have conflicts ‼️ or may have to manually sync it with the target branch 👉❇️\n\n" +
`More info in the [logs 📋](${actionUrl})`,
);
}
}
logger.info("🪄 - Finished updating PRs");
Expand Down
Loading