Do yq test 5. qshift #38
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | | |
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 var | |
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) | |
echo "GITEA_PASSWORD=$GITEA_PASSWORD" >> "$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" | |
- 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: Grab node IP/Port | |
run: | | |
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=https://$CLUSTER_IP:$CLUSTER_PORT" >> "$GITHUB_ENV" | |
- name: List Argo Application ... | |
run: | | |
argocd app list | |
- name: Configure app-config.local.yaml file | |
working-directory: backstage-playground | |
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 | |
ARGOCD_AUTH_TOKEN=123456789 | |
KUBERNETES_API_URL=$API_URL | |
SERVICE_ACCOUNT_TOKEN=$SERVICE_ACCOUNT_TOKEN | |
EOF | |
export $(grep -v '^#' backstage_env_secret.env | xargs) | |
envsubst < manifest/templates/app-config.qshift.tmpl > app-config.local.yaml | |
cat <<EOF >> app-config.local.yaml | |
integrations: | |
gitea: | |
- host: gitea.localtest.me:8443 | |
username: $GITEA_USERNAME | |
password: $GITEA_PASSWORD | |
EOF | |
cat app-config.local.yaml | |
echo "Temporary hack till we remove the non needed cookie env var from the backstage-playground project" | |
sed -i '/: 123456789/d' app-config.local.yaml | |
#- name: Override URLs | |
# uses: mikefarah/yq@v4 | |
# with: | |
# cmd: yq -i '.app.baseUrl = "http://localhost:3000"' backstage-playground/app-config.local.yaml; yq -i '.backend.baseUrl = "http://localhost:7007"' backstage-playground/app-config.local.yaml; yq -i '.backend.cors.origin = "http://localhost:7007"' backstage-playground/app-config.local.yaml | |
- name: Override backstage URLs | |
working-directory: backstage-playground | |
run: | | |
yq -i '.app.baseUrl = "http://localhost:3000"' app-config.local.yaml | |
yq -i '.backend.baseUrl = "http://localhost:7007"' app-config.local.yaml | |
yq -i '.backend.cors.origin = "http://localhost:7007"' app-config.local.yaml | |
cat app-config.local.yaml | |
- name: Launch backstage | |
working-directory: backstage-playground | |
run: | | |
yarn workspace app start & | |
yarn workspace backend start |