mirror of
https://github.com/ditkrg/project-version-check.git
synced 2026-01-22 22:06:42 +00:00
Use github token
Signed-off-by: Shakar <5h4k4r.b4kr@gmail.com>
This commit is contained in:
parent
5d6d6473f7
commit
1939c927d8
2
.github/workflows/main.yaml
vendored
2
.github/workflows/main.yaml
vendored
@ -24,11 +24,11 @@ jobs:
|
|||||||
|
|
||||||
- name: Hello world action step
|
- name: Hello world action step
|
||||||
uses: ./
|
uses: ./
|
||||||
|
|
||||||
id: hello
|
id: hello
|
||||||
with:
|
with:
|
||||||
label: minor
|
label: minor
|
||||||
filePath: package.json
|
filePath: package.json
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
# ${{ github.event.label.name }}
|
# ${{ github.event.label.name }}
|
||||||
- name: Get the output time
|
- name: Get the output time
|
||||||
|
|||||||
@ -7,6 +7,9 @@ inputs:
|
|||||||
filePath:
|
filePath:
|
||||||
description: "File path of the project info (e.g: package.json) relative to the root directory of the repository."
|
description: "File path of the project info (e.g: package.json) relative to the root directory of the repository."
|
||||||
required: true
|
required: true
|
||||||
|
repoToken:
|
||||||
|
description: GitHub repository token
|
||||||
|
required: true
|
||||||
|
|
||||||
outputs:
|
outputs:
|
||||||
time: # id of output
|
time: # id of output
|
||||||
|
|||||||
11
index.js
11
index.js
@ -7,6 +7,7 @@ run();
|
|||||||
async function run() {
|
async function run() {
|
||||||
try {
|
try {
|
||||||
console.log(`CWD: ${process.cwd()}`)
|
console.log(`CWD: ${process.cwd()}`)
|
||||||
|
|
||||||
const label = core.getInput('label');
|
const label = core.getInput('label');
|
||||||
const filePath = `${process.cwd()}/${core.getInput('filePath')}`;
|
const filePath = `${process.cwd()}/${core.getInput('filePath')}`;
|
||||||
|
|
||||||
@ -27,6 +28,7 @@ async function run() {
|
|||||||
|
|
||||||
// the version is in semantic format, so we can split it by dot
|
// the version is in semantic format, so we can split it by dot
|
||||||
const versionParts = version.split('.');
|
const versionParts = version.split('.');
|
||||||
|
// 1.2.3 => [1, 2, 3]
|
||||||
if (label === 'major') {
|
if (label === 'major') {
|
||||||
versionParts[0] = parseInt(versionParts[0]) + 1;
|
versionParts[0] = parseInt(versionParts[0]) + 1;
|
||||||
versionParts[1] = 0;
|
versionParts[1] = 0;
|
||||||
@ -45,7 +47,7 @@ async function run() {
|
|||||||
console.log(versionParts)
|
console.log(versionParts)
|
||||||
// increment the patch version
|
// increment the patch version
|
||||||
// join the parts back together
|
// join the parts back together
|
||||||
const newVersion = `v${versionParts.join('.')}`;
|
const newVersion = versionParts.join('.');
|
||||||
|
|
||||||
|
|
||||||
console.log(`Old version: ${version}. New version: ${newVersion}`)
|
console.log(`Old version: ${version}. New version: ${newVersion}`)
|
||||||
@ -69,6 +71,7 @@ async function run() {
|
|||||||
async function commitChanges(filePath) {
|
async function commitChanges(filePath) {
|
||||||
const commitMessage = 'Commit message here';
|
const commitMessage = 'Commit message here';
|
||||||
const newContent = 'New content to be added';
|
const newContent = 'New content to be added';
|
||||||
|
const githubToken = core.getInput('githubToken');
|
||||||
|
|
||||||
|
|
||||||
// Get the repository owner and name
|
// Get the repository owner and name
|
||||||
@ -93,6 +96,12 @@ async function commitChanges(filePath) {
|
|||||||
{
|
{
|
||||||
content: newContent,
|
content: newContent,
|
||||||
encoding: 'utf-8',
|
encoding: 'utf-8',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
headers: {
|
||||||
|
Accept: 'application/vnd.github.v3+json',
|
||||||
|
Authorization: `Bearer ${githubToken}`,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
console.log('blobResponse: ' + blobResponse.data)
|
console.log('blobResponse: ' + blobResponse.data)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user