Skip to content

Commit ac79b2a

Browse files
authored
Merge pull request #167 from DefangLabs/linda-one-click-deploy-fix
Fix a crucial step in 1-click deploy
2 parents 3058c5e + 299294c commit ac79b2a

File tree

3 files changed

+30
-8
lines changed

3 files changed

+30
-8
lines changed

docs/tutorials/adding-custom-one-click-deploy.md

Lines changed: 30 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,15 @@ description: Add a custom 1-Click Deploy link to deploy your own app.
88

99
This tutorial will show you how to add a 1-Click Deploy link to deploy your app to the Defang Playground.
1010

11-
A 1-Click Deploy link points to a special Defang URL. Clicking this link will trigger a deployment of a project to Defang. The link is often placed as a button in the `README.md` file of your project repository, and is the easiest way to allow anyone to deploy a clone of your app.
11+
The link is often placed as a button in the `README.md` file of your project repository, and is the easiest way to allow anyone to deploy your app.
1212

1313
:::info
1414
If you are trying to use 1-Click Deploy with one of our [samples](https://defang.io/samples/), we have a separate tutorial on [how to use 1-Click Deploy](/docs/tutorials/using-one-click-deploy).
1515
:::
1616

17+
### How 1-Click Deploy Works
18+
A 1-Click Deploy link points to a special URL. Clicking this link will prompt the user to create a new GitHub repo with a clone of your project. This new repo will contain a GitHub Actions workflow which will automatically deploy the project to Defang.
19+
1720
## Pre-requisites
1821

1922
- A [GitHub](https://github.com/) repository for your project
@@ -53,21 +56,40 @@ jobs:
5356
uses: DefangLabs/[email protected]
5457
```
5558
56-
## Step 3 - Get the Encoded URL
59+
## Step 3 - Prepare Your Repository
60+
61+
To support 1-Click Deploy, your repository must be a [Template Repository](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template). In order to make your repository into a Template Repository, complete the following steps:
62+
1. Go to the repository's "Settings" near the right on the top bar.
63+
2. Select the "Template repository" box to turn your repo into a template repo, as seen below:
64+
65+
![select-template-repo-box](/img/custom-one-click-tutorial/select-template-repo-box.png)
66+
67+
3. Go back to your repository's homepage.
68+
4. Click the dropdown menu next to the green "Use this template" button near the top right corner, then click "Create a new repository":
69+
70+
![use-this-template](/img/custom-one-click-tutorial/use-this-template.png)
71+
72+
5. You will be taken to a page similar to the one shown below.
73+
74+
![create-repo](/img/custom-one-click-tutorial/create-repo.png)
75+
76+
Now stay on this page and continue to the next step.
77+
78+
## Step 4 - Get the Encoded URL
5779
58-
You will need the encoded version of your project repository's URL. This will be used as a redirect for the 1-Click Deploy link.
80+
You will need the encoded version of the URL of the page from the previous step. This will be used as a redirect for the 1-Click Deploy link.
5981
60-
1. Copy the URL of your repository's homepage. It should look something like the following:
82+
1. Copy the URL of the page you are on ( "Create a new repository" page sourced from your template repository). It should look something like the following:
6183
```
62-
https://github.com/<your-github-username>/<your-repo-name>
84+
https://github.com/new?template_name=<your-repo-name>&template_owner=<your-github-username>
6385
```
6486
2. You can go online and paste the URL from the step above into a URL encoder tool of your choice. You should end up with an encoded URL, similar to the one shown below:
6587

6688
```
67-
https%3A%2F%2Fgithub.com%2F<your-github-username>%2F<your-repo-name>
89+
https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3D<your-repo-name>%26template_owner%3D<your-github-username>
6890
```
6991

70-
## Step 4 - Create the 1-Click Deploy Link
92+
## Step 5 - Create the 1-Click Deploy Link
7193

7294
You will need to create a 1-Click Deploy link with the following format: `https://portal.defang.dev/redirect?url=` + your encoded URL. This ensures that the user can get [logged in](/docs/concepts/authentication/) to Defang before they get redirected to clone your app for deployment.
7395

@@ -77,7 +99,7 @@ Optionally, you can add `&name=<your-suggested-name>` to the end of the link if
7799

78100
The finished link should look similar to the one below:
79101
```
80-
https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2F<your-github-username>%2F<your-repo-name>&name=<your-suggested-name>
102+
https://portal.defang.dev/redirect?url=https%3A%2F%2Fgithub.com%2Fnew%3Ftemplate_name%3D<your-repo-name>%26template_owner%3D<your-github-username>&name=<your-suggested-name>
81103
```
82104

83105
Now you have a link for anyone to deploy your app to Defang, with just 1 click.
-109 KB
Binary file not shown.
191 KB
Loading

0 commit comments

Comments
 (0)