From 7b040aff2da25c7f945a83bd5e2c0074b24b492a Mon Sep 17 00:00:00 2001 From: GeopJr Date: Thu, 5 Jan 2023 21:43:00 +0200 Subject: [PATCH] feat(ci): comment PR artifact (#816) * chore(issue_templates): remove Yimura from assignees * chore(README): typos, notes, toc * feat(ci): comment artifact nightly.link on PR workflow success --- .github/ISSUE_TEMPLATE/feature_request.yml | 2 - .github/workflows/pr-comment.yml | 61 ++++++++++++++++++++++ README.md | 18 ++++--- 3 files changed, 71 insertions(+), 10 deletions(-) create mode 100644 .github/workflows/pr-comment.yml diff --git a/.github/ISSUE_TEMPLATE/feature_request.yml b/.github/ISSUE_TEMPLATE/feature_request.yml index 2acdd5e0..a2683c0d 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.yml +++ b/.github/ISSUE_TEMPLATE/feature_request.yml @@ -2,8 +2,6 @@ name: Feature request description: Suggest an idea for this project title: "[Request]: " labels: enhancement -assignees: - - Yimura body: - type: textarea attributes: diff --git a/.github/workflows/pr-comment.yml b/.github/workflows/pr-comment.yml new file mode 100644 index 00000000..c9b497e6 --- /dev/null +++ b/.github/workflows/pr-comment.yml @@ -0,0 +1,61 @@ +name: Comment on pull request +on: + workflow_run: + workflows: ['Test workflow with upload'] + types: [completed] +jobs: + pr_comment: + if: github.event.workflow_run.event == 'pull_request' && github.event.workflow_run.conclusion == 'success' + runs-on: ubuntu-latest + steps: + - uses: actions/github-script@v6 + with: + # This snippet is public-domain, taken from + # https://github.com/oprypin/nightly.link/blob/master/.github/workflows/pr-comment.yml + script: | + async function upsertComment(owner, repo, issue_number, purpose, body) { + const {data: comments} = await github.rest.issues.listComments( + {owner, repo, issue_number}); + + const marker = ``; + body = marker + "\n" + body; + + const existing = comments.filter((c) => c.body.includes(marker)); + if (existing.length > 0) { + const last = existing[existing.length - 1]; + core.info(`Updating comment ${last.id}`); + await github.rest.issues.updateComment({ + owner, repo, + body, + comment_id: last.id, + }); + } else { + core.info(`Creating a comment in issue / PR #${issue_number}`); + await github.rest.issues.createComment({issue_number, body, owner, repo}); + } + } + + const {owner, repo} = context.repo; + const run_id = ${{github.event.workflow_run.id}}; + + const pull_requests = ${{ toJSON(github.event.workflow_run.pull_requests) }}; + if (!pull_requests.length) { + return core.error("This workflow doesn't match any pull requests!"); + } + + const artifacts = await github.paginate( + github.rest.actions.listWorkflowRunArtifacts, {owner, repo, run_id}); + if (!artifacts.length) { + return core.error(`No artifacts found`); + } + let body = `Download the artifacts for this pull request:\n`; + for (const art of artifacts) { + body += `\n* [${art.name}.zip](https://nightly.link/${owner}/${repo}/actions/artifacts/${art.id}.zip)`; + } + + core.info("Review thread message body:", body); + + for (const pr of pull_requests) { + await upsertComment(owner, repo, pr.number, + "nightly-link", body); + } \ No newline at end of file diff --git a/README.md b/README.md index bc502df6..3b58613f 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,7 @@ So here I am with an up-to-date menu focusing on protecting the user from toxic ## Table of contents * [How to build](#how-to-build) + * [Curl](#curl) * [Git](#git) * [CMake](#CMake) * [Cloning and generating project files](#cloning-and-generating-project-files) @@ -23,21 +24,21 @@ So here I am with an up-to-date menu focusing on protecting the user from toxic Requirements: - * [Git](#Git) - * [CMake](#CMake) + * [Git](#git) + * [CMake](#cmake) If you have both of the above requirements you can skip to [cloning the git repo and generating the project files](#cloning-and-generating-project-files). ### Curl Curl should be already installed on your computer, but if you are having issues with building the project, you will need to download and install -it. Once Installed run the exe located in bin and it should work +it. [Download Link](https://curl.se/download.html) ### Git -If you haven't installed git on your system go and do so it is **REQUIRED** for setting up a working build environment. +If you haven't installed git on your system go and do so as it is **REQUIRED** for setting up a working build environment. [Download Link](https://git-scm.com/download/win) @@ -63,7 +64,8 @@ CMake is used to generate our project files, if you haven't used it before you w #### Generate project files -#### `NOTE` You will have cd build and cmake again if you add any files or you will get an error when building. +> **Note** +> You will have cd build and cmake again if you add any files or you will get an error when building. - Windows Only @@ -104,7 +106,7 @@ git pull CMake should be handling removed / added files automatically without any user input. -If this is not the case for some reason you'll have to redo the steps in the [Generate project files](#Generate-project-files) section above. +If this is not the case for some reason you'll have to redo the steps in the [Generate project files](#generate-project-files) section above. If you are doing custom modifications to the codebase and have a fork you are on your own for staying up to date with upstream (this repository), google stuff like "merge from upstream" and learn how to use Git. @@ -122,7 +124,7 @@ If you are doing custom modifications to the codebase and have a fork you are on Below is an incomplete list of feature that I believe are notable to this "base" or menu. - Return Native spoofing - - Custom [settings](src/core/globals.hpp) with deep compare if changes were made include auto saving + - Custom [settings](src/core/globals.hpp) with deep compare if changes were made, including auto saving - Clear and well structured source code - Includes a thread pool to queue tasks that shouldn't block the game thread, very similar to fiber pool - Updated natives.hpp from https://nativedb.spyral.dev @@ -130,6 +132,6 @@ Below is an incomplete list of feature that I believe are notable to this "base" ## Contributing -You're free to contribute to YimMenu as long as the feature are useful, not overly toxic, and do not contain anything money related that might get the menu targetted by Take2. +You're free to contribute to YimMenu as long as the features are useful, not overly toxic and do not contain anything money related that might get the menu targeted by Take2. Make sure to read the [CONTRIBUTING.md](CONTRIBUTING.md) file.