|
1 |
| -# This workflow will build a MuleSoft project and deploy to CloudHub |
2 |
| - |
3 | 1 | name: Build and Deploy to Sandbox
|
4 | 2 |
|
5 | 3 | on:
|
6 | 4 | push:
|
7 | 5 | branches: [ sandbox ]
|
8 | 6 | workflow_dispatch:
|
9 | 7 | branches: [ sandbox ]
|
10 |
| - |
| 8 | + |
11 | 9 | jobs:
|
12 |
| - build: |
| 10 | + |
| 11 | + upload_raml: |
13 | 12 | runs-on: ubuntu-latest
|
| 13 | + |
| 14 | + steps: |
| 15 | + - name: Checkout repository |
| 16 | + uses: actions/checkout@v4 |
| 17 | + |
| 18 | + - name: Set up Python environment |
| 19 | + uses: actions/setup-python@v5 |
| 20 | + with: |
| 21 | + python-version: '3.9' |
| 22 | + |
| 23 | + - name: Install dependencies |
| 24 | + run: | |
| 25 | + python -m pip install --upgrade pip |
| 26 | + pip install -r ./scripts/requirements.txt |
| 27 | +
|
| 28 | + - name: Execute exchange-update.py with secrets |
| 29 | + env: |
| 30 | + ORGANIZATION_ID: ${{ secrets.EXCHANGE_UPDATE_ORGANIZATION_ID }} |
| 31 | + API_MANAGER_ENVIRONMENT_ID: ${{ secrets.EXCHANGE_UPDATE_API_MANAGER_ENVIRONMENT_ID }} |
| 32 | + API_MANAGER_INSTANCE_ID: ${{ secrets.EXCHANGE_UPDATE_API_MANAGER_INSTANCE_ID }} |
| 33 | + CLIENT_ID: ${{ secrets.EXCHANGE_UPDATE_CLIENT_ID }} |
| 34 | + CLIENT_SECRET: ${{ secrets.EXCHANGE_UPDATE_CLIENT_SECRET }} |
| 35 | + run: | |
| 36 | + cd scripts |
| 37 | + python exchange-update.py $ORGANIZATION_ID $API_MANAGER_ENVIRONMENT_ID $API_MANAGER_INSTANCE_ID $CLIENT_ID $CLIENT_SECRET |
| 38 | +
|
| 39 | +
|
| 40 | +
|
| 41 | + build_mule: |
| 42 | + needs: upload_raml |
| 43 | + runs-on: ubuntu-latest |
| 44 | + |
14 | 45 | steps:
|
15 |
| - - uses: actions/checkout@v2 |
16 |
| - - uses: actions/cache@v1 |
| 46 | + - name: Checkout repository |
| 47 | + uses: actions/checkout@v4 |
| 48 | + |
| 49 | + - name: Cache Maven repository |
| 50 | + uses: actions/cache@v4 |
17 | 51 | with:
|
18 | 52 | path: ~/.m2/repository
|
19 | 53 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
20 | 54 | restore-keys: |
|
21 | 55 | ${{ runner.os }}-maven-
|
22 |
| - - name: Set up JDK 1.8 |
23 |
| - uses: actions/setup-java@v1 |
24 |
| - with: |
25 |
| - java-version: 1.8 |
26 |
| - - name: Add repo credentials |
27 |
| - |
| 56 | +
|
| 57 | + - name: Set up JDK 17 |
| 58 | + uses: actions/setup-java@v4 |
28 | 59 | with:
|
29 |
| - servers: | |
30 |
| - [{ |
31 |
| - "id": "mule-enterprise", |
32 |
| - "username": "${{ secrets.mule_nexus_username }}", |
33 |
| - "password": "${{ secrets.mule_nexus_password }}" |
34 |
| - }, |
35 |
| - { |
36 |
| - "id": "scores-exchange", |
37 |
| - "username": "${{ secrets.anypoint_cicd_username }}", |
38 |
| - "password": "${{ secrets.anypoint_cicd_password }}" |
39 |
| - }] |
40 |
| - - name: Insert Secret Properties to the .properties file |
| 60 | + distribution: 'adopt' |
| 61 | + java-version: 17 |
| 62 | + |
| 63 | + - name: Set up script permissions |
| 64 | + run: chmod +x ./scripts/deployment-build.sh |
| 65 | + |
| 66 | + - name: Execute deployment-build.sh with secrets |
41 | 67 | env:
|
42 |
| - SFDC_TKN: ${{ secrets.sfdc_sandbox_integrationuser_tkn }} |
43 |
| - SFDC_PASSWORD: ${{ secrets.sfdc_sandbox_integrationuser_pwd }} |
44 |
| - TYPEFORM_CLIENTID: ${{ secrets.typeform_clientid }} |
45 |
| - TYPEFORM_CLIENTSECRET: ${{ secrets.typeform_clientsecret }} |
46 |
| - TYPEFORM_TKN: ${{ secrets.typeform_tkn }} |
| 68 | + KEYSTORE_KEY_PASSWORD: ${{ secrets.KEYSTORE_KEY_PASSWORD }} |
| 69 | + KEYSTORE_PASSWORD: ${{ secrets.KEYSTORE_PASSWORD }} |
47 | 70 | run: |
|
48 |
| - set -e # Exit immediately if a command exits with a non-zero status |
49 |
| - echo "Checking if sandbox.properties file exists:" |
50 |
| - if [ -f src/main/resources/properties/sandbox.properties ]; then |
51 |
| - echo "sandbox.properties file exists." |
52 |
| - else |
53 |
| - echo "Error: sandbox.properties file does not exist." |
54 |
| - exit 1 |
55 |
| - fi |
56 |
| - |
57 |
| - sed -i "s/sfdc.tkn=/sfdc.tkn=${{ secrets.sfdc_sandbox_integrationuser_tkn }}/" src/main/resources/properties/sandbox.properties |
58 |
| - sed -i "s/sfdc.password=/sfdc.password=${{ secrets.sfdc_sandbox_integrationuser_pwd }}/" src/main/resources/properties/sandbox.properties |
59 |
| - sed -i "s/typeform.clientid=/typeform.clientid=${{ secrets.typeform_clientid }}/" src/main/resources/properties/sandbox.properties |
60 |
| - sed -i "s/typeform.clientsecret=/typeform.clientsecret=${{ secrets.typeform_clientsecret }}/" src/main/resources/properties/sandbox.properties |
61 |
| - sed -i "s/typeform.tkn=/typeform.tkn=${{ secrets.typeform_tkn }}/" src/main/resources/properties/sandbox.properties |
62 |
| - - name: Print effective-settings |
63 |
| - run: mvn help:effective-settings |
64 |
| - - name: Print effective-pom |
65 |
| - run: mvn help:effective-pom |
66 |
| - - name: Build with Maven |
67 |
| - run: mvn -B package --file pom.xml |
68 |
| - - name: Stamp artifact file name with commit hash |
69 |
| - run: | |
70 |
| - artifactName1=$(ls target/*.jar | head -1) |
71 |
| - commitHash=$(git rev-parse --short "$GITHUB_SHA") |
72 |
| - artifactName2=$(ls target/*.jar | head -1 | sed "s/.jar/-$commitHash.jar/g") |
73 |
| - mv $artifactName1 $artifactName2 |
74 |
| - - name: Upload artifact |
75 |
| - uses: actions/upload-artifact@master |
| 71 | + cd scripts |
| 72 | + ./deployment-build.sh $KEYSTORE_KEY_PASSWORD $KEYSTORE_PASSWORD |
| 73 | +
|
| 74 | + - name: Upload artifact |
| 75 | + uses: actions/upload-artifact@v4 |
76 | 76 | with:
|
77 |
| - name: artifacts |
78 |
| - path: target/*.jar |
| 77 | + name: artifacts |
| 78 | + path: ./target/*.jar |
79 | 79 |
|
80 |
| - deploy: |
81 |
| - needs: build |
| 80 | + deploy_mule: |
| 81 | + needs: build_mule |
82 | 82 | runs-on: ubuntu-latest
|
83 |
| - steps: |
84 |
| - - uses: actions/checkout@v2 |
85 |
| - - uses: actions/cache@v1 |
| 83 | + |
| 84 | + steps: |
| 85 | + - name: Checkout repository |
| 86 | + uses: actions/checkout@v4 |
| 87 | + |
| 88 | + - name: Cache Maven repository |
| 89 | + uses: actions/cache@v4 |
86 | 90 | with:
|
87 | 91 | path: ~/.m2/repository
|
88 | 92 | key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
|
89 | 93 | restore-keys: |
|
90 | 94 | ${{ runner.os }}-maven-
|
91 |
| - - uses: actions/download-artifact@master |
| 95 | +
|
| 96 | + - name: Download artifact |
| 97 | + uses: actions/download-artifact@v4 |
92 | 98 | with:
|
93 | 99 | name: artifacts
|
94 |
| - - name: Print effective-settings |
95 |
| - run: mvn help:effective-settings |
| 100 | + path: . |
| 101 | + |
| 102 | + # - name: Print effective-settings |
| 103 | + # run: mvn help:effective-settings |
| 104 | + |
96 | 105 | - name: Deploy to Sandbox
|
97 |
| - env: |
98 |
| - USERNAME: ${{ secrets.anypoint_cicd_username }} |
99 |
| - PASSWORD: ${{ secrets.anypoint_cicd_password }} |
100 |
| - SFDC_TKN: ${{ secrets.sfdc_sandbox_integrationuser_tkn }} |
101 |
| - SFDC_PASSWORD: ${{ secrets.sfdc_sandbox_integrationuser_pwd }} |
102 |
| - TYPEFORM_CLIENTID: ${{ secrets.typeform_clientid }} |
103 |
| - TYPEFORM_CLIENTSECRET: ${{ secrets.typeform_clientsecret }} |
104 |
| - TYPEFORM_TKN: ${{ secrets.typeform_tkn }} |
105 | 106 | run: |
|
106 | 107 | artifactName=$(ls *.jar | head -1)
|
107 |
| - mvn deploy -DmuleDeploy -e -Dmule.artifact=$artifactName -Danypoint.username="$USERNAME" -Danypoint.password="$PASSWORD" -Denv=Sandbox -Denv.lowercase=sandbox -Dsfdc.password="$SFDC_SANDBOX_INTEGRATIONUSER_PWD" -Dtypeform.clientid="$TYPEFORM_CLIENTID" -Dtypeform.clientsecret="$TYPEFORM_CLIENTSECRET" -Dtypeform.tkn="$TYPEFORM_TKN" -Dsfdc.tkn="$SFDC_SANDBOX_INTEGRATIONUSER_TKN" -DskipTests |
| 108 | + echo "Deploying artifact $artifactName to the Sandbox environment." |
| 109 | + mvn deploy -DmuleDeploy -e -Dmule.artifact=$artifactName \ |
| 110 | + -Danypoint.username="${{ secrets.ANYPOINT_CICD_USERNAME }}" \ |
| 111 | + -Danypoint.password="${{ secrets.ANYPOINT_CICD_PASSWORD }}" \ |
| 112 | + -Dapp.name=sandbox-salesforce-data-api \ |
| 113 | + -Denv=Sandbox \ |
| 114 | + -Denv.lowercase=sandbox \ |
| 115 | + -Dapi.id="${{ secrets.SANDBOX_API_ID }}" \ |
| 116 | + -Dkeystore.key.password="${{ secrets.KEYSTORE_KEY_PASSWORD }}" \ |
| 117 | + -Dkeystore.password="${{ secrets.KEYSTORE_PASSWORD }}" \ |
| 118 | + -Danypoint.platform.client_id="${{ secrets.ANYPOINT_PLATFORM_CLIENT_ID }}" \ |
| 119 | + -Danypoint.platform.client_secret="${{ secrets.ANYPOINT_PLATFORM_CLIENT_SECRET }}" \ |
| 120 | + -Dsfdc.password="${{ secrets.SFDC_SANDBOX_INTEGRATIONUSER_PWD }}" \ |
| 121 | + -Dsfdc.tkn="${{ secrets.SFDC_SANDBOX_INTEGRATIONUSER_TKN }}" \ |
| 122 | + -Dtypeform.clientid="${{ secrets.TYPEFORM_CLIENTID }}" \ |
| 123 | + -Dtypeform.clientsecret="${{ secrets.TYPEFORM_CLIENTSECRET }}" \ |
| 124 | + -Dtypeform.tkn="${{ secrets.TYPEFORM_TKN }}" \ |
| 125 | + -DskipTests |
| 126 | + |
| 127 | + |
| 128 | + - name: Confirm Deployment |
| 129 | + run: | |
| 130 | + echo "Deployment to Sandbox completed." |
0 commit comments