Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

node20に対応させる #10

Draft
wants to merge 6 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,11 @@ steps:

- name: Generate token
id: generate_token
uses: tibdex/github-app-token@v1
uses: actions/create-github-app-token@v1
with:
app_id: ${{ secrets.APP_ID }}
private_key: ${{ secrets.PRIVATE_KEY }}
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.PRIVATE_KEY }}
owner: ${{ github.repository_owner }}

- name: Sync files
uses: ./.github/actions/sync-files
Expand Down
2 changes: 1 addition & 1 deletion action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,5 +29,5 @@ inputs:


runs:
using: node16
using: node20
main: dist/index.js
64 changes: 64 additions & 0 deletions dist/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.loadConfig = void 0;
const fs_1 = __importDefault(require("fs"));
const path_1 = __importDefault(require("path"));
const js_yaml_1 = require("js-yaml");
const loadConfig = () => {
let config = {
token: fetchActionInput('token'),
username: fetchActionInput('username'),
email: fetchActionInput('email'),
reviewers: fetchActionInput('reviewers').split(','),
teamReviewers: fetchActionInput('team_reviewers').split(','),
workRef: fetchActionInput('work_ref', 'repo-file-sync'),
repos: [],
pr_search_range: fetchActionInput('pr_search_range'),
};
try {
const yaml = loadConfigYaml();
for (const key of Object.keys(yaml)) {
const [full_name, ref] = key.split('@');
const [owner, name] = full_name.split('/');
let repo = {
owner: owner,
name: name,
full_name: full_name,
ref: ref,
files: [],
};
yaml[key].forEach((file) => {
var _a;
(_a = repo.files) === null || _a === void 0 ? void 0 : _a.push({
src: file,
dest: file,
});
});
config.repos.push(repo);
}
}
catch (error) {
if (error instanceof Error) {
throw error;
}
}
return config;
};
exports.loadConfig = loadConfig;
const fetchActionInput = (key, defaultValue = '') => {
return process.env[`INPUT_${key.toUpperCase()}`] || defaultValue;
};
const loadConfigYaml = () => {
const configName = "repo-file-sync";
let configPath = path_1.default.join(process.cwd(), '.github', `${configName}.yml`);
if (!fs_1.default.existsSync(configPath)) {
configPath = path_1.default.join(process.cwd(), '.github', `${configName}.yaml`);
if (!fs_1.default.existsSync(configPath)) {
throw new Error(`Config file not found`);
}
}
return (0, js_yaml_1.load)(fs_1.default.readFileSync(configPath, 'utf8'));
};
Loading