0

使用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();

在创建存储库后尝试自动化我没有在文档中找到一种方法来在阅读工作流语法on.

回购创建的.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 }}."

但是 aworkflow_dispatch需要输入。其他阅读/研究领域:

当从 API 或 中使用组织的模板时,有没有办法触发 Github 操作Use this template

4

0 回答 0