-
Notifications
You must be signed in to change notification settings - Fork 1
181 lines (144 loc) · 6.99 KB
/
backstage.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
name: Install and run backstage
on:
workflow_dispatch:
push:
branches:
- main
env:
IDPBUILDER_VERSION: v0.4.1
YQ_VERSION: v4.44.1
QUAY_ORG: snowdrop
jobs:
setup-idp:
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' && contains( github.event.head_commit.message, 'qshift') }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install idpbuilder
run: |
version=${IDPBUILDER_VERSION}
curl -L -o ./idpbuilder.tar.gz "https://github.com/cnoe-io/idpbuilder/releases/download/${version}/idpbuilder-$(uname | awk '{print tolower($0)}')-$(uname -m | sed 's/x86_64/amd64/').tar.gz"
tar xzf idpbuilder.tar.gz
sudo mv ./idpbuilder /usr/local/bin/
idpbuilder version
- name: Install yq
run: |
yq -V
sudo wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/$YQ_VERSION/yq_linux_amd64
sudo chmod +x /usr/local/bin/yq
- name: Create an IDP cluster and install the packages
run: |
PACKAGES_DIR=.github/resources/idp/packages
idpbuilder create -p $PACKAGES_DIR/tekton -p $PACKAGES_DIR/backstage
- name: Install Argocd client
run: |
curl -sSL -o argocd-linux-amd64 https://github.com/argoproj/argo-cd/releases/latest/download/argocd-linux-amd64
sudo install -m 555 argocd-linux-amd64 /usr/local/bin/argocd
rm argocd-linux-amd64
- name: Set idp env variables
run: |
GITEA_PASSWORD=$(kubectl get secret/gitea-credential -n gitea -ojson | jq -r '.data.password' | base64 -d)
GITEA_USERNAME=$(kubectl get secret/gitea-credential -n gitea -ojson | jq -r '.data.username' | base64 -d)
GITEA_URL=$(kubectl get ingress/my-gitea -n gitea -ojson | jq -r '.spec.rules[0].host')
echo "GITEA_URL=$GITEA_URL" >> "$GITHUB_ENV"
# TODO: To be fixed using new idpbuilder release
# echo "GITEA_PASSWORD=$GITEA_PASSWORD" >> "$GITHUB_ENV"
echo "GITEA_PASSWORD=ghp_S8GMxiyRdd34ttYU" >> "$GITHUB_ENV"
echo "GITEA_USERNAME=$GITEA_USERNAME" >> "$GITHUB_ENV"
ARGO_PASSWORD=$(kubectl get secret/argocd-initial-admin-secret -n argocd -ojson | jq -r '.data.password' | base64 -d)
echo "ARGO_PASSWORD=$ARGO_PASSWORD" >> "$GITHUB_ENV"
echo "ARGO_SERVER=argocd.cnoe.localtest.me:8443" >> "$GITHUB_ENV"
echo "ARGO_USERNAME=admin" >> "$GITHUB_ENV"
SERVICE_ACCOUNT_TOKEN=$(kubectl get secret backstage-secret -n backstage -o json | jq -r '.data.token' | base64 -d)
echo "SERVICE_ACCOUNT_TOKEN=$SERVICE_ACCOUNT_TOKEN" >> "$GITHUB_ENV"
BACKSTAGE_AUTH_SECRET=$(node -p 'require("crypto").randomBytes(24).toString("base64")')
echo "BACKSTAGE_AUTH_SECRET=$BACKSTAGE_AUTH_SECRET" >> "$GITHUB_ENV"
echo "Get node IP and port to access it"
CLUSTER_IP=$(docker inspect localdev-control-plane | jq -r '.[].NetworkSettings.Ports."6443/tcp"[0].HostIp')
CLUSTER_PORT=$(docker inspect localdev-control-plane | jq -r '.[].NetworkSettings.Ports."6443/tcp"[0].HostPort')
echo "API_URL=https://$CLUSTER_IP:$CLUSTER_PORT"
echo "API_URL=$API_URL" >> "$GITHUB_ENV"
- name: Logon to argocd server
run: |
argocd --insecure login $ARGO_SERVER --username $ARGO_USERNAME --password $ARGO_PASSWORD
- name: Checkout QShift backstage playground
uses: actions/checkout@v4
with:
repository: q-shift/backstage-playground
path: backstage-playground
- uses: actions/setup-node@v4
with:
node-version: 20.x
- run: corepack enable
- name: Install & build QShift
working-directory: backstage-playground
run: |
yarn --immutable
yarn tsc
yarn build:all
- name: List Argo Application ...
run: |
argocd app list
- name: Configure app-config.local.yaml file
run: |
cat <<EOF > backstage_env_secret.env
APP_BASE_URL=http://localhost:3000
BACKEND_BASE_URL=http://localhost:7007
BACKSTAGE_AUTH_SECRET=$BACKSTAGE_AUTH_SECRET
TEMPLATE_URL=https://github.com/q-shift/backstage-playground/blob/main/locations/root.yaml
ARGOCD_SERVER=$ARGO_SERVER
ARGOCD_ADMIN_USER=$ARGO_USERNAME
ARGOCD_ADMIN_PASSWORD=$ARGO_PASSWORD
GITHUB_PERSONAL_ACCESS_TOKEN=ghp_S8GMxiyRdd34ttYU
GITEA_URL=$GITEA_URL
GITEA_USERNAME=$GITEA_USERNAME
GITEA_PASSWORD=$GITEA_PASSWORD
KUBERNETES_API_URL=$API_URL
SERVICE_ACCOUNT_TOKEN=$SERVICE_ACCOUNT_TOKEN
EOF
export $(grep -v '^#' backstage_env_secret.env | xargs)
envsubst < .github/resources/app-config.qshift.tmpl > backstage-playground/app-config.local.yaml
cat backstage-playground/app-config.local.yaml
- name: Start backstage
# https://github.com/JarvusInnovations/background-action
uses: JarvusInnovations/background-action@v1
with:
run: yarn dev
wait-on: http://localhost:7007/settings
#- name: Launch backstage
# working-directory: backstage-playground
# run: |
# yarn workspace backend start &
# yarn workspace app start &
# until curl --output /dev/null --head --silent --fail http://localhost:3000; do echo "Wait till backstage is running ...."; sleep 5; done
- name: Import a template
runt: |
curl -s 'http://localhost:7007/api/catalog/locations' \
-X POST \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $BACKSTAGE_AUTH_SECRET" \
--data-raw '{"type":"url","target":"https://github.com/ch007m/test-github-action/blob/main/.github/resources/springboot-grpc-template/template.yaml"}'
- name: Check backstage resources
run: |
echo "Show the locations ..."
curl -s "http://localhost:7007/api/catalog/entities?filter=kind=location" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $BACKSTAGE_AUTH_SECRET" \
--compressed \
| jq -r
- name : Scaffold a project
run: |
curl -s 'http://localhost:7007/api/scaffolder/v2/tasks' \
-X POST \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $BACKSTAGE_AUTH_SECRET" \
-d @.github/resources/scaffold_springboot.json
- name: Check backstage components
run: |
echo "Show the locations ..."
curl -s "http://localhost:7007/api/catalog/entities?filter=kind=component" \
-H 'Content-Type: application/json' \
-H "Authorization: Bearer $BACKSTAGE_AUTH_SECRET" \
--compressed \
| jq -r