Skip to content

Instantly share code, notes, and snippets.

@ShariqT
Created January 6, 2022 02:20
Show Gist options
  • Save ShariqT/1e506df2af606b4ebd5dd06f8972dfac to your computer and use it in GitHub Desktop.
Save ShariqT/1e506df2af606b4ebd5dd06f8972dfac to your computer and use it in GitHub Desktop.
index.js
const github = require("@actions/github")
const core = require("@actions/core")
const { Octokit } = require("@octokit/action");
let gifURLs = [
'https://c.tenor.com/p29xMArwXB8AAAAd/samuel-l-jackson-silly.gif', //silly face sam
'https://c.tenor.com/8aKkFuCN7TsAAAAC/samuel-l-jackson-snakes-on-a-plane.gif', //snakes on a plane
'https://c.tenor.com/PUw8yTi8V5AAAAAC/samuel-l-jackson-shocked.gif', //oh-really-sam?!
'https://c.tenor.com/hIhNfnidIlkAAAAC/butts-release.gif', //jurassic park
'https://c.tenor.com/m36sCPqucWMAAAAC/samuel-jackson-pink.gif' //pink wig sam
]
async function runMain(){
try {
const randInt = function (min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
let message = `<img src="${gifURLs[randInt(0, gifURLs.length - 1)]}" width="200px" /> \n`
const octokit = new Octokit({auth: core.getInput('token')})
let res = await octokit.rest.issues.createComment({
issue_number: github.context.payload.issue.number,
owner: github.context.payload.repository.owner.login,
repo: github.context.payload.repository.name,
body: message + core.getInput('message')
})
console.log(res)
} catch( err ) {
console.log("There was an error executing the action: " + err)
core.setFailed(err.message)
}
}
runMain()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment