Quick Start

In this quickstart, you will do the following automatically with DevStream:

  • create a GitHub repository with automatically generated code for a web application written in Golang with the Gin framework;
  • set up GitHub Actions workflow for the app created in the previous step.

1 Download

In your working directory, run:

Bash

  1. sh -c "$(curl -fsSL https://download.devstream.io/download.sh)"

Note

The command above does the following:

  • find out your OS and chip architecture;
  • find the latest version of the dtm binary;
  • download the correct dtm according to OS/architecture;
  • grant the binary execution permission.

Optional

You can then move dtm to a place which is in your PATH. For example: mv dtm /usr/local/bin/.

For more ways to install dtm, see install dtm.


2 Configuration

Run the following command to generate the template configuration file config.yaml for quickstart.

Bash

  1. ./dtm show config -t quickstart > config.yaml

Then set the following environment variables by running (replace values within the double quotes):

Bash

  1. export GITHUB_USER="<YOUR_GITHUB_USER_NAME_HERE>"
  2. export DOCKERHUB_USERNAME="<YOUR_DOCKER_HUB_USER_NAME_HERE>"
  3. export IMAGE_REPO_PASSWORD="<YOUR_DOCKER_HUB_USER_NAME_HERE>"
  4. export GITHUB_TOKEN="<YOUR_GITHUB_PERSONAL_ACCESS_TOKEN_HERE>"

Tip

Go to Personal Access Token to generate a new GITHUB_TOKEN for dtm.

For “Quick Start”, you only need repo,workflow,delete_repo permissions.

Then you should run the following commands to update our config file with those env vars:

macOS or FreeBSD based systemsGNU Linux users

Bash

  1. sed -i.bak "s@YOUR_GITHUB_USERNAME_CASE_SENSITIVE@${GITHUB_USER}@g" config.yaml
  2. sed -i.bak "s@YOUR_DOCKER_USERNAME@${DOCKERHUB_USERNAME}@g" config.yaml

Bash

  1. sed -i "s@YOUR_GITHUB_USERNAME_CASE_SENSITIVE@${GITHUB_USER}@g" config.yaml
  2. sed -i "s@YOUR_DOCKER_USERNAME@${DOCKERHUB_USERNAME}@g" config.yaml

3 Init

Run:

Bash

  1. ./dtm init -f config.yaml

4 Apply

Run:

Bash

  1. ./dtm apply -f config.yaml -y

5 Check the Results

Go to your GitHub repositories list and you can see the new repo go-webapp-devstream-demo has been created.

There is scaffolding code for a Golang web app in it, with GitHub Actions CI workflow set up properly.

The commits (made by DevStream when scaffolding the repo and creating workflows) have triggered the CI, and the workflow has finished successfully, as shown in the screenshot below:

Quick Start - 图1


6 Clean Up

Run:

Bash

  1. ./dtm delete -f config.yaml

Input y then press enter to continue, and you should see similar output:

Output

  1. 2022-12-12 12:29:00 [INFO] Delete started.
  2. 2022-12-12 12:29:00 [INFO] Using local backend. State file: devstream.state.
  3. 2022-12-12 12:29:00 [INFO] Tool (github-actions/default) will be deleted.
  4. 2022-12-12 12:29:00 [INFO] Tool (repo-scaffolding/golang-github) will be deleted.
  5. Continue? [y/n]
  6. Enter a value (Default is n): y
  7. 2022-12-12 12:29:00 [INFO] Start executing the plan.
  8. 2022-12-12 12:29:00 [INFO] Changes count: 2.
  9. 2022-12-12 12:29:00 [INFO] -------------------- [ Processing progress: 1/2. ] --------------------
  10. 2022-12-12 12:29:00 [INFO] Processing: (github-actions/default) -> Delete ...
  11. 2022-12-12 12:29:02 [INFO] Prepare to delete 'github-actions_default' from States.
  12. 2022-12-12 12:29:02 [SUCCESS] Tool (github-actions/default) delete done.
  13. 2022-12-12 12:29:02 [INFO] -------------------- [ Processing progress: 2/2. ] --------------------
  14. 2022-12-12 12:29:02 [INFO] Processing: (repo-scaffolding/golang-github) -> Delete ...
  15. 2022-12-12 12:29:03 [SUCCESS] GitHub repo go-webapp-devstream-demo removed.
  16. 2022-12-12 12:29:03 [INFO] Prepare to delete 'repo-scaffolding_golang-github' from States.
  17. 2022-12-12 12:29:03 [SUCCESS] Tool (repo-scaffolding/golang-github) delete done.
  18. 2022-12-12 12:29:03 [INFO] -------------------- [ Processing done. ] --------------------
  19. 2022-12-12 12:29:03 [SUCCESS] All plugins deleted successfully.
  20. 2022-12-12 12:29:03 [SUCCESS] Delete finished.

Now if you check your GitHub repo list again, everything has been nuked by DevStream. Hooray!

You can also remove the DevStream state file (which should be empty now) by running: rm devstream.state.