Skip to content

Commit 721ff0e

Browse files
authored
FIX: deployment workflow (#70)
* UPD: fix format issues with yarn.lock * ADD: setup techdocs * UPD: update cd workflow and config file * UPD: config file
1 parent 459e865 commit 721ff0e

File tree

14 files changed

+4537
-9311
lines changed

14 files changed

+4537
-9311
lines changed

.github/workflows/cd-workflow.yaml

Lines changed: 45 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,55 +1,65 @@
1-
name: Deploy backstage
1+
name: Deploy Backstage
22

33
on:
4-
push:
5-
branches:
6-
- main
7-
pull_request:
8-
branches:
9-
- main
4+
workflow_run:
5+
workflows: ["CI Workflow"]
6+
types:
7+
- completed
108

119
jobs:
1210
create-and-push-image:
1311
permissions:
1412
id-token: write
15-
contents: read
16-
name: "Create and push the Docker image to GAR"
13+
contents: read # Remove if not required
14+
15+
name: "Create and Push Docker Image to GAR"
1716
runs-on: ubuntu-latest
1817
defaults:
1918
run:
2019
shell: bash
2120

2221
steps:
23-
- name: Checkout
22+
- name: Checkout Repository
2423
uses: actions/checkout@v4
2524

26-
- id: 'setup-qemu'
27-
name: Set up QEMU
25+
- name: Set up QEMU
26+
id: setup-qemu
2827
uses: docker/setup-qemu-action@v3
2928

30-
- id: 'docker-buildx-setup'
31-
name: Set up Docker Buildx
29+
- name: Set up Docker Buildx
30+
id: docker-buildx-setup
3231
uses: docker/setup-buildx-action@v3
3332

34-
- name: 'Authenticate to Google Cloud'
35-
id: 'auth'
36-
uses: 'google-github-actions/auth@v2'
33+
- name: Authenticate to Google Cloud
34+
id: auth
35+
uses: google-github-actions/auth@v1
3736
with:
38-
create_credentials_file: true
39-
token_format: "access_token"
37+
#create_credentials_file: true
38+
token_format: access_token
4039
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
4140
service_account: ${{ secrets.GCP_DEPLOY_SA }}
4241

43-
- name: "Login to GAR"
44-
id: 'login-gar'
42+
- name: Set up GCP SDK
43+
uses: google-github-actions/setup-gcloud@v1
44+
with:
45+
version: "latest"
46+
project_id: ${{ secrets.GCP_PROJECT_ID }}
47+
48+
- name: Login to GAR
49+
id: login-gar
4550
uses: docker/login-action@v3
4651
with:
47-
registry: ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_GAR_REPO }}
52+
registry: ${{ secrets.GCP_REGION }}-docker.pkg.dev
4853
username: oauth2accesstoken
4954
password: ${{ steps.auth.outputs.access_token }}
5055

51-
- id: 'build-and-push'
52-
name: 'Build and Push docker Image'
56+
- name: Configure Docker for Artifact Registry
57+
run: |
58+
gcloud auth configure-docker \
59+
${{ secrets.GCP_REGION }}-docker.pkg.dev
60+
61+
- name: Build and Push Docker Image
62+
id: build-and-push
5363
uses: docker/build-push-action@v5
5464
with:
5565
push: true
@@ -60,44 +70,37 @@ jobs:
6070
build-args: |
6171
APP_ENV=docker
6272
63-
6473
deploy-image:
6574
permissions:
6675
id-token: write
67-
contents: read
76+
contents: read # Remove if not required
6877

69-
name: "Deploy image on cloud run"
78+
name: "Deploy Image on Cloud Run"
7079
runs-on: ubuntu-latest
80+
needs: create-and-push-image
7181
defaults:
7282
run:
7383
shell: bash
74-
needs: create-and-push-image
7584

7685
steps:
77-
- name: Checkout
86+
- name: Checkout Repository
7887
uses: actions/checkout@v4
7988

80-
- id: 'auth'
81-
name: 'Authenticate to Google Cloud'
82-
uses: 'google-github-actions/auth@v2'
83-
with:
84-
create_credentials_file: true
85-
workload_identity_provider: ${{ secrets.GCP_WORKLOAD_IDENTITY_PROVIDER }}
86-
service_account: ${{ secrets.GCP_DEPLOY_SA }}
87-
8889
- name: Deploy to Cloud Run
89-
id: 'deploy'
90-
uses: 'google-github-actions/deploy-cloudrun@v2'
90+
id: deploy
91+
uses: google-github-actions/deploy-cloudrun@v2
9192
with:
9293
service: ${{ secrets.GCP_CLOUD_RUN_SERVICE }}
9394
image: ${{ secrets.GCP_REGION }}-docker.pkg.dev/${{ secrets.GCP_PROJECT_ID }}/${{ secrets.GCP_GAR_REPO }}/backstage-image:${{ github.sha }}
9495
region: ${{ secrets.GCP_REGION }}
95-
flags: '--platform managed --allow-unauthenticated --port=7007'
96-
secrets: |-
96+
flags: |
97+
--platform managed
98+
--allow-unauthenticated
99+
--port=7007
100+
secrets: |
97101
GITHUB_TOKEN=github_token:latest
98102
GITLAB_TOKEN=gitlab_token:latest
99103
GOOGLE_CLIENT_ID=google_client_id:latest
100104
GOOGLE_CLIENT_SECRET=google_client_secret:latest
101105
PROD_GITHUB_CLIENT_SECRET=github_client_secret:latest
102106
PROD_GITHUB_CLIENT_ID=github_client_id:latest
103-

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,5 +57,6 @@ pg_values.yaml
5757

5858
*secret.yaml
5959

60+
.vscode/
6061

6162
key/

.vscode/extensions.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"recommendations": [
3+
"redhat.vscode-yaml"
4+
]
5+
}

app-config.yaml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ integrations:
3535
token: ${GITLAB_TOKEN}
3636

3737
techdocs:
38-
builder: 'local' # Alternatives - 'external'
39-
generator:
40-
runIn: 'docker' # Alternatives - 'local'
38+
builder: 'external'
4139
publisher:
42-
type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.
40+
type: 'googleGcs'
41+
googleGcs:
42+
bucketName: 'backstage-codeidp-techdocs'
43+
projectId: code-idp
44+
credentials: ./key/code-idp-e144f8987002.json
4345

4446
# scaffolder:
4547

@@ -56,7 +58,11 @@ catalog:
5658
rules:
5759
- allow: [Template]
5860
- type: file
59-
target: ./examples/template/template.yaml
61+
target: ./examples/template/register-component.yaml
62+
rules:
63+
- allow: [Template]
64+
- type: file
65+
target: ./examples/template/sample-document.yaml
6066
rules:
6167
- allow: [Template]
6268

catalog-info.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,14 @@ metadata:
77
It also enables users to store, view and discover information about projects in CODE.
88
annotations:
99
github.com/project-slug: 'codeuniversity/code-idp'
10-
# backstage.io/techdocs-ref: dir:.
10+
backstage.io/techdocs-ref: dir:.
1111
spec:
1212
type: website
1313
owner: code_idp_team
1414
lifecycle: production
1515

1616
---
17+
1718
apiVersion: backstage.io/v1alpha1
1819
kind: Component
1920
metadata:
@@ -35,4 +36,4 @@ spec:
3536
displayName: Infrastructure Team
3637
3738
children: []
38-
members: [Yvette]
39+
members: [Yvette...]
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# How to publish your documentation
2+
3+
You need the following things prepared to document a component:
4+
5+
* A [registered component](./how-to-register-a-component.md) (You can also do
6+
both setups, registration of the component and the documentation together in
7+
one go).
8+
9+
## Set the configuration file for MkDocs
10+
11+
* A file named `mkdocs.yml` in the root of the repository.
12+
13+
!!! example "mkdocs.yml file with techdocs configuration"
14+
15+
```yaml
16+
site_name: Publish Documentation Example
17+
docs_dir: docs
18+
plugins:
19+
- techdocs-core
20+
```
21+
22+
## Add annotation for documentation
23+
24+
You need to create the definition `annotations:` inside the `metadata:` section
25+
of your component and add the key `backstage.io/techdocs-ref` annotation in the
26+
`catalog-info.yaml` file.
27+
28+
!!! example "catalog-info.yaml file with techdocs information"
29+
30+
```yaml
31+
apiVersion: backstage.io/v1alpha1
32+
kind: Component
33+
metadata:
34+
#...
35+
annotations:
36+
backstage.io/techdocs-ref: dir:.
37+
#...
38+
```
39+
40+
## Add documentation
41+
42+
Create a directory called `docs`, define a file called `index.md` or `readme.md`,
43+
this will be the main page of your documentation.
44+
45+
Inside this you can `docs` directory you should be able to use Markdown files
46+
`*.md` to define your documentation.
47+
48+
### Formatting and capabilities
49+
50+
Documentation is formatted mainly using [MkDocs syntax](https://www.mkdocs.org/user-guide/writing-your-docs/),
51+
also with [Material for MkDocs features](https://squidfunk.github.io/mkdocs-material/reference/)
52+
and some specific features added to [Backstage](https://backstage.io/) as
53+
plugins.
54+
55+
56+
## References
57+
58+
* [TechDocs Documentation in Backstage](https://backstage.io/docs/features/techdocs/)

docs/how-to-register-a-component.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# How to register a component and define service dependency and RTO
1+
# How to register a component and define service dependency
22

33
## Register a new service(component)
44

docs/index.md

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,18 @@
1-
# Getting Started with CODE-IDP
1+
# Getting Started
22

3+
CODE-IDP is the platform to automate deployment of node and flask applications, centralize software components(Microservices, Websites, Libraries, APIs, Data pipelines, ML models ) and publish technical documentation.
4+
5+
Current components defined can be found in the [Catalog home]()
6+
7+
Documentation defined per service can be found in the [Documentation section]()
8+
9+
## Deploy your application
10+
11+
- [Quick tutorial to deploy your application](./how-to-deploy-your-app.md)
12+
13+
14+
## Register and Document Your Software Projects
15+
16+
- [Register your components](./how-to-register-a-component.md)
17+
18+
- [Publish documentaion](./how-to-publish-documentation.md)
File renamed without changes.
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: backstage.io/v1alpha1
2+
kind: Component
3+
metadata:
4+
name: sample-document
5+
annotations:
6+
backstage.io/techdocs-ref: dir:.
7+
spec:
8+
type: documentation
9+
lifecycle: experimental
10+
owner: guests
11+
system: examples

0 commit comments

Comments
 (0)