Skip to content

Commit

Permalink
intial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Carlgo11 committed Jan 27, 2024
0 parents commit 1dbf050
Show file tree
Hide file tree
Showing 5 changed files with 303 additions and 0 deletions.
Empty file added .gitignore
Empty file.
25 changes: 25 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: 'Issue title updater'
description: 'Issue title updater for 2factorauth'
author: 'Carlgo11'
inputs:
data:
description: 'Issue data'
required: true
repository:
description: 'The full name of the repository'
required: true
owner:
description: 'The owner of the repository'
required: true
token:
description: 'GitHub Token'
required: true
issue_number:
description: 'GitHub Issue number'
required: true
issue_labels:
description: 'Issue labels'
required: true
runs:
using: 'node20'
main: 'index.js'
34 changes: 34 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
const core = require('@actions/core');
const github = require('@actions/github');
const {Octokit} = require('@octokit/core');

async function run() {
const octokit = new Octokit({
auth: core.getInput('token')
})
const labels = JSON.parse(core.getInput('labels'))
let prefix = '';
for (const label of labels) {
switch (label.name) {
case 'add site':
prefix = 'Add';
break;
case 'update site':
prefix = 'Update';
break;
}
}
const data = JSON.parse(core.getInput('data'))
const site_name = data['site-name'].text
return await octokit.request('PATCH /repos/{owner}/{repo}/issues/{issue_number}', {
owner: core.getInput('owner'),
repo: core.getInput('repository'),
issue_number: core.getInput('issue_number'),
title: `${prefix} ${site_name}`,
headers: {
'X-GitHub-Api-Version': '2022-11-28'
}
})
}

run().catch(error => core.setFailed(error.message));
228 changes: 228 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"name": "issue_title_updater",
"version": "0.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "node index.js"
},
"author": "Carlgo11",
"license": "MIT",
"dependencies": {
"@actions/core": "^1.10.1",
"@actions/github": "^6.0.0",
"@octokit/core": "^5.1.0"
}
}

0 comments on commit 1dbf050

Please sign in to comment.