问题描述
使用 octokit 可以创建存在于组织中的存储库:
require("dotenv").config();
const { Octokit } = require("@octokit/rest");
const cwa = new Octokit({
auth: process.env.TOKEN,//create Github personal token
});
const main = async (name) => {
try {
await cwa.repos.createUsingTemplate({
template_owner: process.env.OWNER,template_repo: "org-template-repo",name,});
console.log("repository successfully create ?");
} catch (e) {
console.log("error:",e);
}
};
main();
在创建存储库后尝试自动化我在文档中没有找到在阅读 Workflow syntax 和 on
后检测模板存储库创建的方法。
repo-created.yml:
name: Repo Template Used
on: [created]
jobs:
greet-when-created:
runs-on: ubuntu-latest
steps:
- run: echo "? The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "? This job is Now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "? The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v2
- run: echo "? The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "?️ The workflow is Now ready to test your code on the runner."
- name: List files in the repository
run: |
ls ${{ github.workspace }}
- run: echo "? This job's status is ${{ job.status }}."
但是 workflow_dispatch
需要输入。更多阅读/研究领域:
- Workflow commands for GitHub Actions
- Events that trigger workflows
- Promote consistency across your organization with workflow templates
- How to create repository for organization using github-api?
当从 API 或使用此模板使用组织的模板时,是否有办法触发 Github 操作?
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)