init
This commit is contained in:
commit
3ffd290a66
31
action.yml
Normal file
31
action.yml
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
name: 'Online Code Pages'
|
||||||
|
description: 'Place the code in Pages.'
|
||||||
|
inputs:
|
||||||
|
ref:
|
||||||
|
description: >
|
||||||
|
The branch, tag or SHA to deployment. When checking out the repository that
|
||||||
|
triggered a workflow, this defaults to the reference or SHA for that
|
||||||
|
event. Otherwise, uses the default branch.
|
||||||
|
default: ${{ gitea.sha }}
|
||||||
|
token:
|
||||||
|
description: >
|
||||||
|
Personal access token (PAT) used to fetch the repository. The PAT is configured
|
||||||
|
with the local git config, which enables your scripts to run authenticated git
|
||||||
|
commands. The post-job step removes the PAT.
|
||||||
|
|
||||||
|
|
||||||
|
We recommend using a service account with the least permissions necessary.
|
||||||
|
Also when generating a new PAT, select the least scopes necessary.
|
||||||
|
|
||||||
|
|
||||||
|
[Learn more about creating and using encrypted secrets](https://help.github.com/en/actions/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)
|
||||||
|
default: ${{ gitea.token }}
|
||||||
|
pages-url:
|
||||||
|
description: The base URL for the Online Code Pages instance that you are trying to clone from, will use environment defaults to fetch from the same instance that the workflow is running from unless specified. Example URLs are https://pages.wikiwiki.li/ or https://my-pages.example.com/
|
||||||
|
default: https://pages.wikiwiki.li/
|
||||||
|
remove:
|
||||||
|
description: Remove placed codes.
|
||||||
|
default: false
|
||||||
|
runs:
|
||||||
|
using: node16
|
||||||
|
main: index.js
|
70
index.js
Normal file
70
index.js
Normal file
@ -0,0 +1,70 @@
|
|||||||
|
"use strict";
|
||||||
|
|
||||||
|
const https = require('https');
|
||||||
|
|
||||||
|
const token = process.env.INPUT_TOKEN;
|
||||||
|
const repository = process.env.GITHUB_REPOSITORY;
|
||||||
|
const owner = process.env.GITHUB_REPOSITORY_OWNER;
|
||||||
|
const pagesControl = process.env["INPUT_PAGES-URL"] + "control.php";
|
||||||
|
const pagesLogs = process.env["INPUT_PAGES-URL"] + "getlogs.php";
|
||||||
|
const ref = process.env.INPUT_REF;
|
||||||
|
const remove = JSON.parse(process.env.INPUT_REMOVE.toLowerCase());
|
||||||
|
|
||||||
|
const data = JSON.stringify({
|
||||||
|
repository: repository,
|
||||||
|
owner: owner,
|
||||||
|
token: token,
|
||||||
|
ref: ref,
|
||||||
|
remove: remove,
|
||||||
|
});
|
||||||
|
|
||||||
|
const options = {
|
||||||
|
method: "POST",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
|
};
|
||||||
|
const url = pagesControl;
|
||||||
|
const request = https.request(url, options, response => {
|
||||||
|
console.log('statusCode:', response.statusCode);
|
||||||
|
|
||||||
|
let body = "";
|
||||||
|
response.on('data', (d) => {
|
||||||
|
body += d;
|
||||||
|
});
|
||||||
|
|
||||||
|
response.on('end', () => {
|
||||||
|
if (response.statusCode < 200 || 299 < response.statusCode) {
|
||||||
|
process.exitCode = 1;
|
||||||
|
console.log(body);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(`processID: ${body}`);
|
||||||
|
let log = "";
|
||||||
|
const getLogs = () => {
|
||||||
|
const req = https.request(pagesLogs + "?processId=" + body, (res) => {
|
||||||
|
let logBody = "";
|
||||||
|
res.on('data', (chunk) => {
|
||||||
|
logBody += chunk;
|
||||||
|
});
|
||||||
|
res.on('end', () => {
|
||||||
|
const logData = JSON.parse(logBody);
|
||||||
|
process.stdout.write(logData["log"].slice(log.length));
|
||||||
|
log = logData["log"];
|
||||||
|
if (!logData["finished"]) {
|
||||||
|
setTimeout(getLogs, 1000);
|
||||||
|
} else if (!logData["succeed"]) {
|
||||||
|
process.exitCode = 1;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
req.end();
|
||||||
|
};
|
||||||
|
setTimeout(getLogs, 1000);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
request.write(data);
|
||||||
|
request.end();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user