Skip to content

Commit f13e7e3

Browse files
swaldmannchgeo
andauthored
Documentation for cds add github-actions (#2033)
Added some documentation for `cds add github-actions` + how to set up a sandbox subaccount the way we did for github.com/capire. --------- Co-authored-by: Christian Georgi <chgeo@users.noreply.github.com>
1 parent 3909549 commit f13e7e3

File tree

3 files changed

+110
-5
lines changed

3 files changed

+110
-5
lines changed
18.2 KB
Loading
29.3 KB
Loading

guides/deployment/cicd.md

Lines changed: 110 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,116 @@ status: released
1616
[[toc]]
1717

1818

19+
20+
21+
## GitHub Actions
22+
23+
GitHub offers continuous integration using [GitHub Actions](https://docs.github.com/en/actions/automating-builds-and-tests/about-continuous-integration). In our [samples](https://github.com/capire/samples), we use simple workflows to [test, deploy and release new versions](https://github.com/capire/samples/tree/main/.github/workflows).
24+
25+
Add a default set of workflows to your project like so:
26+
27+
```sh
28+
cds add github-actions
29+
```
30+
> You can also use `cds add gha` as a shortcut.
31+
32+
### Deploy to Staging
33+
34+
The created workflows do a _Staging_ deployment for pushes on the `main` branch, for example after merging pull requests.
35+
36+
If no defaults are maintained in your GitHub org, a set of variables and secrets has to be provided. Open the repository and navigate here to maintain them:
37+
38+
`Settings``Secrets and variables``Actions`
39+
40+
For a minimal deployment setup, these variables and secrets are required:
41+
42+
#### Cloud Foundry
43+
44+
| **Type** | **Name** | **Note** | **Example** |
45+
|------------|----------------|-----------|-------------------|
46+
| Variable | `CF_API` | API URL | `https://api.cf.example.com` |
47+
| | `CF_USERNAME` | Username | `user@example.com` |
48+
| | `CF_ORG` | Org Name | `my-org` |
49+
| | `CF_SPACE` | Space Name| `my-space` |
50+
| Secret | `CF_PASSWORD` | Password | `********` |
51+
52+
#### Kyma
53+
54+
| **Type** | **Name** | **Note** | **Example** |
55+
|------------|----------------|-----------|-------------------|
56+
| Secret | `KUBE_CONFIG` | Base64-encoded Kubernetes config | see below |
57+
58+
59+
::: details Example of a decoded `KUBE_CONFIG`
60+
61+
Your `KUBE_CONFIG` will have to look similar to this. Make sure to replace `token` by an authorization token created for your technical user used for deployment.
62+
63+
```yaml{6-7,11}
64+
apiVersion: v1
65+
kind: Config
66+
clusters:
67+
- name: default-cluster
68+
cluster:
69+
certificate-authority-data: ...
70+
server: https://api.<server ID>.stage.kyma.ondemand.com
71+
users:
72+
- name: ci-user
73+
user:
74+
token: ...
75+
contexts:
76+
- name: ci-context
77+
context:
78+
cluster: default-cluster
79+
namespace: ci
80+
user: ci-user
81+
current-context: ci-context
82+
```
83+
[Learn more about configuring Kubernetes](./to-kyma#configure-kubernetes){.learn-more style="margin-top:20px"}
84+
85+
:::
86+
87+
#### BTP Prerequisites
88+
89+
Also make sure sufficient service entitlements are assigned to your subaccount depending on your expected usage.
90+
91+
::: tip Set up a sandbox subaccount as an org-wide default
92+
93+
Organization variables and secrets allow you to provide defaults for new projects without prior setup.
94+
95+
Once required for your use case, you can easily **overwrite org-wide** variables and secrets by **repository-local** ones.
96+
:::
97+
98+
#### You're set!
99+
100+
You can now simply push any CAP project that was set up using `cds add github-actions` to your org. When merging PRs or pushing to your `main` branch, the deployment workflow will start and after some time a new entry will show up in the _Deployments_ section on your repository front page:
101+
102+
![](./assets/github-deployment.png){style="max-width: 200px"} <!-- = image-width/2 -->
103+
104+
### Create a GitHub Release
105+
106+
#### Prerequisites
107+
108+
For the actual release we want to override org-wide sandbox variables to deploy to a different subaccount/organization and database.
109+
110+
Go to `Settings``Environments``New environment` → enter "Production".
111+
112+
Now override org-wide variables (e.g. `CF_ORG` and `CF_SPACE` in Cloud Foundry) to use a dedicated subaccount you created for the release deployment.
113+
114+
#### Publish the release
115+
116+
On your repository front page go to `Releases``Draft a new release``Select tag`.
117+
118+
Now enter a tag name, e.g. `v1.0.0` and select `Create new tag: v1.0.0 on publish`.
119+
120+
You can optionally add a release title and release notes. Hit **Publish release** once you're ready.
121+
122+
The release will show up in your _Releases_ page and a deployment to your production environment is started. Once finished, a _Production_ entry shows up next to _Staging_:
123+
124+
![](./assets/github-release.png){style="max-width: 268px"} <!-- = image-width/2 -->
125+
126+
127+
128+
19129
<span id="afterstart" />
20130

21131
<span id="beforecicd" />
@@ -35,8 +145,3 @@ For more flexibility you can set up continuous delivery in your software develop
35145
Try the tutorial [Create Automated System Tests for SAP Cloud Application Programming Model Projects](https://developers.sap.com/tutorials/cicd-wdi5-cap.html) to create system tests against a CAP-based sample application and automate your tests through a CI/CD pipeline.
36146

37147
[See a comparison with SAP Continuous Integration and Delivery Service.](https://www.project-piper.io/){.learn-more}
38-
39-
## GitHub Actions
40-
41-
GitHub offers continuous integration workflows using [GitHub Actions](https://docs.github.com/en/actions/automating-builds-and-tests/about-continuous-integration). In our [SFlight sample,](https://github.com/SAP-samples/cap-sflight) we use GitHub Actions in two simple workflows to test our samples on [current Node.js and Java versions](https://github.com/SAP-samples/cap-sflight/tree/main/.github/workflows).
42-

0 commit comments

Comments
 (0)