diff --git a/.github/workflows/up-to-date.yml b/.github/workflows/up-to-date.yml index b80b7a9..93f183a 100644 --- a/.github/workflows/up-to-date.yml +++ b/.github/workflows/up-to-date.yml @@ -7,6 +7,7 @@ on: jobs: updatePullRequests: + name: Keep PRs up to date runs-on: ubuntu-latest steps: - name: Update all the PRs diff --git a/README.md b/README.md index 4886e61..4f44232 100644 --- a/README.md +++ b/README.md @@ -24,6 +24,7 @@ on: jobs: updatePullRequests: + name: Keep PRs up to date runs-on: ubuntu-latest steps: - name: Update all the PRs diff --git a/action.yml b/action.yml index d90f590..263857d 100644 --- a/action.yml +++ b/action.yml @@ -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' diff --git a/package.json b/package.json index d060d70..6ddcae8 100644 --- a/package.json +++ b/package.json @@ -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": { diff --git a/src/github/pullRequest.ts b/src/github/pullRequest.ts index 04ca1fb..39502a4 100644 --- a/src/github/pullRequest.ts +++ b/src/github/pullRequest.ts @@ -45,4 +45,12 @@ export class PullRequestApi { return data.message; } + + async comment(number: number, msg: string): Promise { + await this.api.rest.issues.createComment({ + ...this.repo, + issue_number: number, + body: msg, + }); + } } diff --git a/src/index.ts b/src/index.ts index 01e7b3e..f8d5592 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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); @@ -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");