Skip to content

Commit b9a30dc

Browse files
Merge pull request #299 from AmericaSCORESBayArea/sandbox
Oct 27, 2024: Sandbox to Production
2 parents 4a3f9d5 + 73a2efe commit b9a30dc

29 files changed

+2620
-820
lines changed
+99-76
Original file line numberDiff line numberDiff line change
@@ -1,107 +1,130 @@
1-
# This workflow will build a MuleSoft project and deploy to CloudHub
2-
31
name: Build and Deploy to Sandbox
42

53
on:
64
push:
75
branches: [ sandbox ]
86
workflow_dispatch:
97
branches: [ sandbox ]
10-
8+
119
jobs:
12-
build:
10+
11+
upload_raml:
1312
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+
1445
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
1751
with:
1852
path: ~/.m2/repository
1953
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
2054
restore-keys: |
2155
${{ 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
2859
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
4167
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 }}
4770
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
7676
with:
77-
name: artifacts
78-
path: target/*.jar
77+
name: artifacts
78+
path: ./target/*.jar
7979

80-
deploy:
81-
needs: build
80+
deploy_mule:
81+
needs: build_mule
8282
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
8690
with:
8791
path: ~/.m2/repository
8892
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
8993
restore-keys: |
9094
${{ runner.os }}-maven-
91-
- uses: actions/download-artifact@master
95+
96+
- name: Download artifact
97+
uses: actions/download-artifact@v4
9298
with:
9399
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+
96105
- 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 }}
105106
run: |
106107
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."

.github/workflows/production-on-push-build-and-deploy.yml

+168-3
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,174 @@ on:
66
workflow_dispatch:
77

88
jobs:
9-
build-and-deploy:
9+
10+
upload_raml:
11+
runs-on: ubuntu-latest
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
17+
- name: Set up Python environment
18+
uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.9'
21+
22+
- name: Install dependencies
23+
run: |
24+
python -m pip install --upgrade pip
25+
pip install -r ./scripts/requirements.txt
26+
27+
- name: Execute exchange-update.py with secrets
28+
env:
29+
ORGANIZATION_ID: ${{ secrets.EXCHANGE_UPDATE_ORGANIZATION_ID }}
30+
API_MANAGER_ENVIRONMENT_ID: ${{ secrets.PRODUCTION_EXCHANGE_UPDATE_API_MANAGER_ENVIRONMENT_ID }}
31+
API_MANAGER_INSTANCE_ID: ${{ secrets.PRODUCTION_EXCHANGE_UPDATE_API_MANAGER_INSTANCE_ID }}
32+
CLIENT_ID: ${{ secrets.EXCHANGE_UPDATE_CLIENT_ID }}
33+
CLIENT_SECRET: ${{ secrets.EXCHANGE_UPDATE_CLIENT_SECRET }}
34+
run: |
35+
cd scripts
36+
python exchange-update.py $ORGANIZATION_ID $API_MANAGER_ENVIRONMENT_ID $API_MANAGER_INSTANCE_ID $CLIENT_ID $CLIENT_SECRET
37+
38+
39+
40+
build_mule:
41+
needs: upload_raml
1042
runs-on: ubuntu-latest
43+
1144
steps:
12-
- name: Print a message
13-
run: echo "Hello, this is a test message!"
45+
- name: Checkout repository
46+
uses: actions/checkout@v4
47+
48+
- name: Cache Maven repository
49+
uses: actions/cache@v4
50+
with:
51+
path: ~/.m2/repository
52+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
53+
restore-keys: |
54+
${{ runner.os }}-maven-
55+
56+
- name: Set up JDK 17
57+
uses: actions/setup-java@v4
58+
with:
59+
distribution: 'adopt'
60+
java-version: 17
61+
62+
- name: Set up script permissions
63+
run: chmod +x ./scripts/deployment-build.sh
64+
65+
- name: Set up script permissions 2
66+
run: chmod +x ./scripts/disable-validations.sh
67+
68+
- name: Disable validations & execute deployment-build.sh with secrets
69+
env:
70+
KEYSTORE_KEY_PASSWORD: ${{ secrets.PRODUCTION_KEYSTORE_KEY_PASSWORD }}
71+
KEYSTORE_PASSWORD: ${{ secrets.PRODUCTION_KEYSTORE_PASSWORD }}
72+
run: |
73+
cd scripts
74+
./disable-validations.sh
75+
./deployment-build.sh $KEYSTORE_KEY_PASSWORD $KEYSTORE_PASSWORD
76+
77+
- name: Upload artifact
78+
uses: actions/upload-artifact@v4
79+
with:
80+
name: artifacts
81+
path: ./target/*.jar
82+
83+
deploy_mule:
84+
needs: build_mule
85+
runs-on: ubuntu-latest
86+
87+
steps:
88+
- name: Checkout repository
89+
uses: actions/checkout@v4
90+
91+
- name: Cache Maven repository
92+
uses: actions/cache@v4
93+
with:
94+
path: ~/.m2/repository
95+
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
96+
restore-keys: |
97+
${{ runner.os }}-maven-
98+
99+
- name: Download artifact
100+
uses: actions/download-artifact@v4
101+
with:
102+
name: artifacts
103+
path: .
104+
105+
# - name: Print effective-settings
106+
# run: mvn help:effective-settings
107+
108+
- name: Deploy to Production
109+
run: |
110+
artifactName=$(ls *.jar | head -1)
111+
echo "Deploying artifact $artifactName to the Production environment."
112+
mvn deploy -DmuleDeploy -e -Dmule.artifact=$artifactName \
113+
-Danypoint.username="${{ secrets.ANYPOINT_CICD_USERNAME }}" \
114+
-Danypoint.password="${{ secrets.ANYPOINT_CICD_PASSWORD }}" \
115+
-Dapp.name=production-salesforce-data-api \
116+
-Denv=Production \
117+
-Denv.lowercase=production \
118+
-Dapi.id="${{ secrets.PRODUCTION_API_ID }}" \
119+
-Dkeystore.key.password="${{ secrets.PRODUCTION_KEYSTORE_KEY_PASSWORD }}" \
120+
-Dkeystore.password="${{ secrets.PRODUCTION_KEYSTORE_PASSWORD }}" \
121+
-Danypoint.platform.client_id="${{ secrets.ANYPOINT_PLATFORM_CLIENT_ID }}" \
122+
-Danypoint.platform.client_secret="${{ secrets.ANYPOINT_PLATFORM_CLIENT_SECRET }}" \
123+
-Dsfdc.password="${{ secrets.SFDC_PROD_INTEGRATIONUSER_PWD }}" \
124+
-Dsfdc.tkn="${{ secrets.SFDC_PROD_INTEGRATIONUSER_TKN }}" \
125+
-Dtypeform.clientid="${{ secrets.TYPEFORM_CLIENTID }}" \
126+
-Dtypeform.clientsecret="${{ secrets.TYPEFORM_CLIENTSECRET }}" \
127+
-Dtypeform.tkn="${{ secrets.TYPEFORM_TKN }}" \
128+
-DskipTests
129+
130+
131+
- name: Confirm Deployment
132+
run: |
133+
echo "Deployment to Sandbox completed."
134+
135+
create-release:
136+
needs: deploy_mule
137+
runs-on: ubuntu-latest
138+
steps:
139+
- name: Checkout code
140+
uses: actions/checkout@v4
141+
142+
- name: Execute version.sh to determine new tag
143+
id: determine_version
144+
run: |
145+
chmod +x ./scripts/version.sh
146+
new_tag=$(./scripts/version.sh)
147+
echo "::set-output name=new_tag::$new_tag"
148+
149+
- name: Create Release
150+
id: create_release
151+
uses: actions/create-release@v1
152+
env:
153+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
154+
with:
155+
tag_name: ${{ steps.determine_version.outputs.new_tag }}
156+
release_name: Release ${{ steps.determine_version.outputs.new_tag }}
157+
body: "Release of the production-salesforce-data-api"
158+
draft: false
159+
prerelease: false
14160

161+
- name: Download artifact
162+
uses: actions/download-artifact@v4
163+
with:
164+
name: artifacts
165+
path: .
166+
167+
- name: Capture artifact file path
168+
id: get_file
169+
run: echo "FILE_PATH=$(ls ./*.jar)" >> $GITHUB_ENV
170+
171+
- name: Upload artifact to release
172+
uses: actions/upload-release-asset@v1
173+
env:
174+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
175+
with:
176+
upload_url: ${{ steps.create_release.outputs.upload_url }}
177+
asset_path: ${{ env.FILE_PATH }}
178+
asset_name: production-salesforce-data-api-${{ steps.determine_version.outputs.new_tag }}.jar
179+
asset_content_type: application/java-archive

0 commit comments

Comments
 (0)