Skip to content

Test template. play #56

Test template. play

Test template. play #56

Workflow file for this run

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