github-repo-scaffolding-golang Plugin

This plugin bootstraps a GitHub repo with scaffolding code for a Golang web application.

This plugin depends on the following environment variable:

  • GITHUB_TOKEN

Set it before using this plugin.

If you don’t know how to create this token, check out: - Creating a personal access token

Tips:

1. If you run dtm delete, the repo on GitHub will be completely removed.

2. If the Update interface is called, the repo on github will be completely removed and recreated. However, given our current implementation, this interface shall not be called, as of in v0.2.0.

Usage

Please note that the owner parameter is case-sensitive.

  1. tools:
  2. # name of the tool
  3. - name: github-repo-scaffolding-golang
  4. # id of the tool instance
  5. instanceID: default
  6. # format: name.instanceID; If specified, dtm will make sure the dependency is applied first before handling this tool.
  7. dependsOn: []
  8. # options for the plugin
  9. options:
  10. # the repo's owner. It should be case-sensitive here; strictly use your GitHub user name; please change the value below.
  11. owner: YOUR_GITHUB_USERNAME
  12. # the repo's org. If you set this property, then the new repo will be created under the org you're given, and the "owner" setting above will be ignored.
  13. org: YOUR_ORGANIZATION_NAME
  14. # the repo which you'd like to create; please change the value below.
  15. repo: YOUR_REPO_NAME
  16. # the branch of the repo you'd like to hold the code
  17. branch: main
  18. # the image repo you'd like to push the container image; please change the value below.
  19. image_repo: YOUR_DOCKERHUB_USERNAME/YOUR_DOCKERHUB_REPOSITORY

Replace the following from the config above:

  • YOUR_GITHUB_USERNAME
  • YOUR_ORGANIZATION_NAME
  • YOUR_REPO_NAME
  • YOUR_DOCKERHUB_USERNAME
  • YOUR_DOCKERHUB_REPOSITORY

The “branch” in the example above is “main”, but you can adjust accordingly.

Currently, all the parameters in the example above are mandatory.

Outputs

This plugin has three outputs:

If, for example, you want to use the outputs as inputs for another plugin, you can refer to the following example:

  1. ---
  2. tools:
  3. - name: go-webapp-repo
  4. plugin: github-repo-scaffolding-golang
  5. options:
  6. owner: YOUR_GITHUB_USERNAME
  7. repo: YOUR_REPO_NAME
  8. branch: main
  9. image_repo: YOUR_DOCKERHUB_REPOSITORY
  10. - name: golang-demo-actions
  11. plugin: githubactions-golang
  12. dependsOn: ["go-webapp-repo.github-repo-scaffolding-golang"]
  13. options:
  14. owner: ${{go-webapp-repo.github-repo-scaffolding-golang.outputs.owner}}
  15. repo: ${{go-webapp-repo.github-repo-scaffolding-golang.outputs.repo}}
  16. language:
  17. name: go
  18. version: "1.17"
  19. branch: main
  20. build:
  21. enable: True
  22. test:
  23. enable: True
  24. coverage:
  25. enable: True
  26. docker:
  27. enable: False

Pay attention to the ${{ xxx }} part in the example. ${{ TOOL_NAME.PLUGIN.outputs.var}} is the syntax for using an output.