Skip to content
This repository has been archived by the owner on Oct 8, 2024. It is now read-only.

Solo PR preview comments #11

Merged
merged 5 commits into from
Apr 16, 2021
Merged

Solo PR preview comments #11

merged 5 commits into from
Apr 16, 2021

Conversation

bdougie
Copy link
Member

@bdougie bdougie commented Apr 13, 2021

What is this?

The staging GitHub Action flow prints too many comments and this PR adds more context to remove the previous comments.

What's next

#13

Opened the issue to potentially move the script to a new file as mentioned here.

          github
          .request(
            `GET /repos/${context.repo.owner}/${context.repo.repo}/issues/${context.issue.number}/comments`
          )
          .then(({ data }) => {
            console.log(data)
            for (var i = 0; i < data.length; i++) { 
              if (data[i].user.login !== "github-actions[bot]") { continue; } // skip is not printed the a github-actions[bot]
              if (data[i].body.includes("deploy is ready")) {
                console.log("You found it")
                github.issues.deleteComment({
                  owner: context.repo.owner,
                  repo: context.repo.repo,
                  comment_id: data[i].id,
                });
              }
            }
            if (data.length === 0) {
              console.log("No comments found");
            }
          });  
          
          github.issues.createComment({
            issue_number: context.issue.number,
            owner: context.repo.owner,
            repo: context.repo.repo,
            body: `This deploy is ready to be previewed! ${ process.env.LINK }`
          })

@bdougie bdougie temporarily deployed to staging April 13, 2021 21:05 Inactive
@bdougie bdougie temporarily deployed to staging April 16, 2021 03:46 Inactive
@bdougie bdougie temporarily deployed to staging April 16, 2021 03:56 Inactive
@bdougie bdougie merged commit a8140c3 into main Apr 16, 2021
@bdougie bdougie deleted the unique-pr-commenting branch April 16, 2021 04:08
@github-actions
Copy link

This deploy is ready to be previewed! http://slaybot-staging.azurewebsites.net

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant