Skip to content

Commit

Permalink
add simple githubaction
Browse files Browse the repository at this point in the history
  • Loading branch information
alperdedeoglu committed Oct 7, 2024
1 parent 92062c7 commit 84f9b58
Show file tree
Hide file tree
Showing 2 changed files with 81 additions and 3 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/ci-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: CI for Pull Requests

on:
pull_request:
branches:
- main # Run the workflow for PRs targeting the "main" branch

jobs:
test:
runs-on: ubuntu-latest

steps:
# Step 1: Check out the code from the PR branch
- name: Checkout code
uses: actions/checkout@v2

# Step 2: Set up Node.js
- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '20.x'

# Step 3: Install MBT and dependencies
- name: Install MBT and dependencies
run: |
npm install -g mbt
cd code
npm install --production
# Step 4: Install CF Cli
- name: Install CF Cli
run: |
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key | sudo apt-key add -
echo "deb https://packages.cloudfoundry.org/debian stable main" | sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list
# Step 5: Install Multiapps Plugin
- name: Install Multiapps Plugin
run: |
cf add-plugin-repo CF-Community https://plugins.cloudfoundry.org
cf install-plugin multiapps -f
# Step 6: Login to CF
- name: Log in to Cloud Foundry
run: |
cf login -u ${{ secrets.CF_USERNAME }} -p ${{ secrets.CF_PASSWORD }} -o ${{ secrets.CF_ORG }} -s ${{ secrets.CF_SPACE }} -a ${{ secrets.CF_API }}
# Step 7: Build the project
- name: Build MTA Archive
run: |
cd deploy/cf
mbt build
# Step 8: Verify MTA Archive built successfully
- name: Deploy to CF
run: |
cf deploy ./deploy/cf/mta_archives/susaas_0.0.1.mtar
28 changes: 25 additions & 3 deletions code/broker/start.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,34 @@

import Broker from '@sap/sbf';

// If this is a CI CD deployment we get broker credentials from env and hardcode the catalog.
if (process.env.cicd) {
const catalog = `{
"services": [
{
"name": "susaas-api",
"description": "Sustainable SaaS API",
"bindable": true,
"plans": [
{
"name": "default",
"description": "Standard Plan",
"id": "57030d69-3e2d-4dd9-a138-21f16b542dff"
}
],
"id": "6dec18a5-4742-450f-8840-ef9df0331b20"
}
]
}`
let brokerConfig = { brokerCredentials: { [process.env["BROKER_USER"]]: process.env["BROKER_PASSWORD"] }, catalog: JSON.parse(catalog) }
new Broker(brokerConfig).start()
}
// If VCAP_APPLICATION is defined, we are in a Cloud Foundry scenario
// For local testing, the USER and PASSWORD are always injected via environment variables
if(process.env.VCAP_APPLICATION && process.env.NODE_ENV === "production"){
else if (process.env.VCAP_APPLICATION && process.env.NODE_ENV === "production" && process.env.cicd !== true) {
new Broker().start();
}else{
} else {
// In production Kyma scenarios and local testing, BROKER_USER and BROKER_PASSWORD are passed in env variables
let brokerConfig = { brokerCredentials : { [process.env["BROKER_USER"]] : process.env["BROKER_PASSWORD"] }}
let brokerConfig = { brokerCredentials: { [process.env["BROKER_USER"]]: process.env["BROKER_PASSWORD"] } }
new Broker(brokerConfig).start()
}

0 comments on commit 84f9b58

Please sign in to comment.