Skip to content

Commit

Permalink
Merge branch 'main' into logo-feature
Browse files Browse the repository at this point in the history
  • Loading branch information
BMG93 authored May 8, 2024
2 parents dc154ef + efc8ee1 commit f398518
Show file tree
Hide file tree
Showing 4 changed files with 158 additions and 11 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/ci-workflow.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: CI Workflow

on:
push:
branches:
- '**'
pull_request:
branches:
- '**'

jobs:
setup_and_test:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: ['18.x', '20.x']

steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0

- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: ${{ matrix.node-version }}
cache: 'yarn'

- name: Check Node.js version
run: node -v

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Lint code
run: yarn lint:all

- name: Build projects
run: yarn build:all

- name: Test projects
run: yarn test:all

validate_commit_messages:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Ensure full git history
run: |
if [ -f $(git rev-parse --git-dir)/shallow ]; then
git fetch --prune --unshallow
else
git fetch --prune origin
fi
- name: Validate Commit Messages
run: |
commit_messages=$(git log --format=%B origin/main..HEAD)
echo "Checking commit messages: $commit_messages"
IFS=$'\n'
for message in $commit_messages; do
if [[ "$message" =~ ^Merge ]]; then
echo "Skipping merge commit: $message"
elif ! echo "$message" | grep -Pq '^(ADD:|FIX:|DEL:|UPD:) .+'; then
echo "Invalid commit message: '$message'"
echo "Commit messages must start with ADD:, FIX:, DEL:, or UPD:"
exit 1
fi
done
echo "All commit messages adhere to the format."
validate_branch_names:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Validate Branch Names
run: |
if [ "${{ github.event_name }}" == "pull_request" ]; then
if [ -z "${{ github.head_ref }}" ]; then
branch_name=$(echo $GITHUB_REF | sed -n 's/refs\/heads\/\([^/]*\)/\1/p')
echo "Extracted branch name from ref: $branch_name"
else
branch_name=${{ github.head_ref }}
echo "Running in a fork pull request with branch: $branch_name"
fi
else
branch_name=$(git rev-parse --abbrev-ref HEAD)
echo "Current branch: $branch_name"
fi
if ! echo "$branch_name" | grep -Eq '^(main|feature/.+|hotfix/.+)$'; then
echo "Error: Branch name $branch_name does not fit the naming convention."
exit 1
fi
echo "Branch name fits the naming convention."
16 changes: 10 additions & 6 deletions app-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ backend:
client: pg
connection:
host: ${POSTGRES_HOST}
port: ${POSTGRES_PORT}
user: ${POSTGRES_USER}
port: ${POSTGRES_PORT}
user: ${POSTGRES_USER}
password: ${POSTGRES_PASSWORD}

integrations:
Expand All @@ -35,7 +35,6 @@ techdocs:
publisher:
type: 'local' # Alternatives - 'googleGcs' or 'awsS3'. Read documentation for using alternatives.


catalog:
import:
entityFilename: catalog-info.yaml
Expand Down Expand Up @@ -64,13 +63,18 @@ catalog:
rules:
- allow: [Template]

- type: file
target: ../../packages/backend/src/templates/initiate-deployment.yaml
rules:
- allow: [Template]

auth:
# see https://backstage.io/docs/auth/ to learn about auth providers
environment: development
providers:
providers:
github:
development:
clientId: ${GITHUB_CLIENT_ID}
clientId: ${GITHUB_CLIENT_ID}
clientSecret: ${GITHUB_CLIENT_SECRET}

kubernetes:
Expand All @@ -80,7 +84,7 @@ kubernetes:
- type: config
clusters:
- url: ${K8S_URL}
name: "k8s"
name: 'k8s'
authProvider: serviceAccount
skipTLSVerify: false
skipMetricsLookup: true
Expand Down
48 changes: 48 additions & 0 deletions packages/backend/src/templates/initiate-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
apiVersion: scaffolder.backstage.io/v1beta3
# https://backstage.io/docs/features/software-catalog/descriptor-format#kind-template
kind: Template
metadata:
name: GKE-cluster
title: Initiate Deployment.
description: Deploy application to google cloud for the first time or update an existing deployment.
spec:
owner: user:guest
type: service

# These parameters are used to generate the input form in the frontend, and are
# used to gather input data for the execution of the template.
parameters:
- title: Public github repo link to deploy
required:
- repoUrl
properties:
repoUrl:
title: Public github Repo to deploy
description: Provide the github repository link in the following format <https://github.com/your_user_name/your_repository_name>
pattern: ^https:\/\/github\.com\/[a-zA-Z0-9_-]+\/[a-zA-Z0-9_-]
type: string
ui:options:
allowedHosts:
- github.com
action:
title: Action
default: create
# Note changing these paramters will lead to not triggering the github actions, it must be create or update.
description: Action to perform (create new deployment for application/Update for updating an already deployed application)
enum:
- create
- update

# These steps are executed in the scaffolder backend, using data that we gathered
# via the parameters above.
steps:
# Start a github Action to build a GKE cluster with Terraform
- id: github-action
name: Trigger Github Action
action: github:actions:dispatch
input:
workflowId: ${{parameters.action}}-image.yml
repoUrl: 'github.com?repo=idp-hosted-projects&owner=codeuniversity'
branchOrTagName: 'main'
workflowInputs:
githubRepo: ${{ parameters.repoUrl }}
10 changes: 5 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -8915,7 +8915,6 @@
resolved "https://registry.yarnpkg.com/@types/range-parser/-/range-parser-1.2.7.tgz#50ae4353eaaddc04044279812f52c8c65857dbcb"
integrity sha512-hKormJbkJqzQGhziax5PItDUTMAM9uE2XXQmM37dyd4hVM+5aVl7oVxMVUiVQn2oCQFN/LKCZdvSM0pFRqbSmQ==

"@types/react-dom@*", "@types/react-dom@^18", "@types/react-dom@^18.0.0":
"@types/react-dom@*", "@types/react-dom@^18", "@types/react-dom@^18.0.0":
version "18.2.19"
resolved "https://registry.yarnpkg.com/@types/react-dom/-/react-dom-18.2.19.tgz#b84b7c30c635a6c26c6a6dfbb599b2da9788be58"
Expand Down Expand Up @@ -8954,10 +8953,10 @@
dependencies:
"@types/react" "*"

"@types/react@^16.13.1 || ^17.0.0":
version "17.0.75"
resolved "https://registry.yarnpkg.com/@types/react/-/react-17.0.75.tgz#cffbc76840a12fcadaf5a3cf14878bb06efcf73d"
integrity sha512-MSA+NzEzXnQKrqpO63CYqNstFjsESgvJAdAyyJ1n6ZQq/GLgf6nOfIKwk+Twuz0L1N6xPe+qz5xRCJrbhMaLsw==
"@types/react@*", "@types/react@^16.13.1 || ^17.0.0", "@types/react@^16.13.1 || ^17.0.0 || ^18.0.0", "@types/react@^18":
version "18.2.63"
resolved "https://registry.yarnpkg.com/@types/react/-/react-18.2.63.tgz#4637c56146ad90f96d0583171edab953f7e6fe57"
integrity sha512-ppaqODhs15PYL2nGUOaOu2RSCCB4Difu4UFrP4I3NHLloXC/ESQzQMi9nvjfT1+rudd0d2L3fQPJxRSey+rGlQ==
dependencies:
"@types/prop-types" "*"
"@types/scheduler" "*"
Expand Down Expand Up @@ -9760,6 +9759,7 @@ anymatch@^3.0.3, anymatch@~3.1.2:
"@backstage/plugin-techdocs-react" "^1.1.15"
"@backstage/plugin-user-settings" "^0.8.0"
"@backstage/theme" "^0.5.0"
"@circleci/backstage-plugin" "^0.1.1"
"@material-ui/core" "^4.12.2"
"@material-ui/icons" "^4.9.1"
history "^5.0.0"
Expand Down

0 comments on commit f398518

Please sign in to comment.