Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const core = require('@actions/core')
const { Toolkit } = require('actions-toolkit')
const fm = require('front-matter')
const nunjucks = require('nunjucks')
const dateFilter = require('nunjucks-date-filter')
function listToArray (list) {
if (!list) return []
return Array.isArray(list) ? list : list.split(', ')
}
Toolkit.run(async tools => {
const template = core.getInput('filename') || '.github/ISSUE_TEMPLATE.md'
const assignees = core.getInput('assignees')
const env = nunjucks.configure({ autoescape: false })
env.addFilter('date', dateFilter)
const templateVariables = {
...tools.context,
date: Date.now()
}
// Get the file
tools.log.debug('Reading from file', template)
const file = tools.getFile(template)
// Grab the front matter as JSON
const { attributes, body } = fm(file)
const { Toolkit } = require( 'actions-toolkit' );
Toolkit.run( async ( tools ) => {
try {
const { action, issue } = tools.context.payload;
if( action !== 'opened' ){
tools.exit.neutral( `Event ${ action } is not supported by this action.` )
}
// Get the arguments
const projectName = tools.arguments._[ 0 ];
const columnName = tools.arguments._[ 1 ];
const secret = process.env.GH_PAT ? process.env.GH_PAT : process.env.GITHUB_TOKEN;
// Fetch the column ids and names
const { resource } = await tools.github.graphql({
query: `query {
resource( url: "${ issue.html_url }" ) {
const { Toolkit } = require('actions-toolkit')
// Run your GitHub Action!
Toolkit.run(async tools => {
tools.exit.success('We did it!')
})
deployedCommit: process.env.GITHUB_SHA,
deployedBranch: process.env.GITHUB_REF,
};
if (!actionConfig.zeitToken) {
throw new Error(`ZEIT_TOKEN environment variable is not set`);
}
const zeitAPIClient = axios.create({
baseURL: 'https://api.zeit.co',
headers: { Authorization: `Bearer ${actionConfig.zeitToken}` },
params: { teamId: actionConfig.teamId },
});
// Run your GitHub Action!
Toolkit.run(async tools => {
function fetchLastDeployment(params) {
return zeitAPIClient
.get('/v4/now/deployments', { params })
.then(({ data }) => data.deployments[0]);
}
const strategies = [
fetchLastDeployment({ 'meta-commit': actionConfig.deployedCommit }),
fetchLastDeployment({ 'meta-branch': actionConfig.deployedBranch }),
fetchLastDeployment({ limit: 1 }),
];
let deploymentUrl;
let deploymentCommit;
let deploymentProjectName;
const {Toolkit} = require('actions-toolkit');
const {withDefaults} = require('actions-toolkit/lib/graphql');
Toolkit.run(async tools => {
// Re-authenticate with the correct secret.
tools.github.graphql = withDefaults(process.env.GRAPHQL_TOKEN);
// Ensure that the actor of the triggering action belongs to the core team
const actorLogin = tools.context.actor;
const teamResponse = await tools.github.graphql(`
query {
organization(login: "atom") {
team(slug: "github-package") {
members(first: 100) {
nodes {
login
}
}
}
}
return `āļø ${capitalize(item.payload.action)} issue #${
item.payload.issue.number
} in ${item.repo.name}`
},
PullRequestEvent: item => {
const emoji = item.payload.action === 'opened' ? 'šŖ' : 'ā'
const line = item.payload.pull_request.merged
? 'š Merged'
: `${emoji} ${capitalize(item.payload.action)}`
return `${line} PR #${item.payload.pull_request.number} in ${
item.repo.name
}`
}
}
Toolkit.run(
async tools => {
const { GIST_ID, GH_USERNAME, GH_PAT } = process.env
// Get the user's public events
tools.log.debug(`Getting activity for ${GH_USERNAME}`)
const events = await tools.github.activity.listPublicEventsForUser({
username: GH_USERNAME,
per_page: 100
})
tools.log.debug(
`Activity for ${GH_USERNAME}, ${events.data.length} events found.`
)
const content = events.data
// Filter out any boring activity
.filter(event => serializers.hasOwnProperty(event.type))
const { Toolkit } = require('actions-toolkit')
const fetch = require('node-fetch')
const hash = require('object-hash')
Toolkit.run(async tools => {
// Serialize payload object
const payload = {
...tools.context.payload,
'smee-action': {
action: tools.context.action,
actor: tools.context.actor,
event: tools.context.event,
sha: tools.context.sha,
ref: tools.context.ref,
workflow: tools.context.workflow
}
}
// Serialize headers
const headers = {
'X-GitHub-Event': tools.context.event,
const { Toolkit } = require('actions-toolkit')
const getConfig = require('./utils/config')
const CONFIG_FILENAME = 'pr-lint.yml'
const defaults = {
projects: ['PROJ'],
check_title: true,
check_branch: false,
check_commits: false,
ignore_case: false
}
Toolkit.run(
async tools => {
const { repository, pull_request } = tools.context.payload
const repoInfo = {
owner: repository.owner.login,
repo: repository.name,
ref: pull_request.head.ref
}
const config = {
...defaults,
...(await getConfig(tools.github, CONFIG_FILENAME, repoInfo))
}
const title = config.ignore_case ?
pull_request.title.toLowerCase() :
const { Toolkit } = require('actions-toolkit');
const diff = require('diff-lines');
const normalizeNewline = require('normalize-newline');
Toolkit.run(
async tools => {
const owner = tools.context.payload.repository.owner.login;
const repo = tools.context.payload.repository.name;
const response = await tools.github.pulls.list({
owner,
repo,
head: 'SAP:' + tools.context.payload.ref.replace('refs/heads/', ''),
});
const relatedPullRequests = response.data;
if (relatedPullRequests.length === 0) {
return;
}