Deploy and Integration Test #31
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
# This job will run only once PR will get merge under specified branch. | |
# Once PR is merged, then this workflow will trigger the deploy-job & if it completes only then the followup job (Integration test) runs. | |
name: Deploy and Integration Test | |
on: | |
pull_request: | |
types: [closed] | |
branches: | |
- develop | |
workflow_dispatch: | |
permissions: | |
pull-requests: read | |
jobs: | |
deploy: | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Use Node.js 20.x | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20.x | |
- name: Login to Cloud Foundry | |
run: | | |
wget -q -O - https://packages.cloudfoundry.org/debian/cli.cloudfoundry.org.key \ | |
| sudo tee /etc/apt/trusted.gpg.d/cloudfoundry.asc | |
echo "deb https://packages.cloudfoundry.org/debian stable main" \ | |
| sudo tee /etc/apt/sources.list.d/cloudfoundry-cli.list | |
sudo apt update | |
sudo apt install cf-cli | |
cf login -a ${{ secrets.CF_API }} -u ${{ secrets.CF_USER }} -p ${{ secrets.CF_PASSWORD }} -o ${{ secrets.CF_ORG }} -s ${{ secrets.CF_SPACE }} | |
- name: Clone and prepare projects & Build and deploy | |
run: | | |
git clone --single-branch --branch develop https://github.com/cap-js/sdm.git | |
git clone --single-branch --branch sdmIncidents https://github.com/cap-js/incidents-app.git | |
cd sdm | |
npm pack | |
echo "Current directory" | |
pwd | |
ls | |
mv *.tgz ../incidents-app | |
cd ../incidents-app | |
npm i *.tgz | |
- name: Build and deploy | |
run: | | |
cd incidents-app | |
wget -P /tmp https://github.com/SAP/cloud-mta-build-tool/releases/download/v1.2.28/cloud-mta-build-tool_1.2.28_Linux_amd64.tar.gz | |
tar -xvzf /tmp/cloud-mta-build-tool_1.2.28_Linux_amd64.tar.gz | |
sudo mv mbt /usr/local/bin/ | |
npm i @sap/cds-dk -g | |
mbt build | |
cf install-plugin multiapps -f | |
cf deploy mta_archives/sdmincidents_1.0.0.mtar -f | |
integration-test: | |
needs: deploy | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v2 | |
- name: Setup Node.js environment | |
uses: actions/[email protected] | |
with: | |
node-version: '20' | |
- name: Run integration tests | |
run: | | |
appUrl=${{ secrets.CF_ORG }}-${{ secrets.CF_SPACE }}-incidents-srv.cfapps.eu12.hana.ondemand.com | |
echo "app url: ${appUrl}" | |
# JSON file path | |
JSON_FILE="test/integration/credentials.json" | |
# Modify JSON file | |
jq --arg appUrl "$appUrl" --arg authUrl "${{ secrets.CAPAUTH_URL }}" --arg clientID "${{ secrets.CAPSDM_CLIENT_ID }}" --arg clientSecret "${{ secrets.CAPSDM_CLIENT_SECRET }}" --arg username "${{ secrets.CF_USER }}" --arg password "${{ secrets.CF_PASSWORD }}" \ | |
'.appUrl = $appUrl | .authUrl = $authUrl | .clientID = $clientID | .clientSecret = $clientSecret | .username = $username | .password = $password' $JSON_FILE > "temp.json" \ | |
&& mv "temp.json" $JSON_FILE | |
cat $JSON_FILE | |
npm i | |
npm run integration-test |