Skip to content

Commit

Permalink
Support both workflow_dispatch and repository_dispatch
Browse files Browse the repository at this point in the history
Signed-off-by: Zheng Chang <zhengchang@microsoft.com>
  • Loading branch information
Zheng Chang committed Nov 5, 2021
1 parent cf79725 commit ed802ea
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 39 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/setupWlsAksDependency.yml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ jobs:
# sample request
curl --verbose -X POST https://api.github.com/repos/${{ github.repository_owner }}/weblogic-azure/dispatches -H 'Accept: application/vnd.github.everest-preview+json' -H 'Authorization: token <personal_access_token>' --data '<request_data>'
# copy the JSON as <request_data>
{"event_type": "aks-integration-test-without-dependency-creation", "client_payload": {"isForDemo": "false", "disambiguationSuffix": "${{ github.run_id }}", "storageAccountName": "${{ env.storageAccountName }}", "storageContainerName": "${{ env.storageContainerName }}", "dbName": "${{ env.dbName }}"}}
{"event_type": "aks-integration-test-without-dependency-creation", "client_payload": {"gitUserNameForArtifactsLocation": "${{ github.repository_owner }}", "testBranchNameForArtifactsLocation": "${{ github.ref }}", "isForDemo": "false", "disambiguationSuffix": "${{ github.run_id }}", "storageAccountName": "${{ env.storageAccountName }}", "storageContainerName": "${{ env.storageContainerName }}", "dbName": "${{ env.dbName }}"}}
EOF
- name: Archive integration-test-data.txt
uses: actions/upload-artifact@v1
Expand Down
43 changes: 32 additions & 11 deletions .github/workflows/testWlsAksWithDependencyCreation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
inputs:
isForDemo:
description: 'If set to true, JMS configuration for Cargo Tracker will be applied, and resources will not be deleted'
description: 'If set to true, resources will not be deleted'
required: true
default: 'false'
gitUserNameForArtifactsLocation:
Expand All @@ -16,7 +16,7 @@ on:
required: true
default: main
# sample cURL
# curl --verbose -X POST https://api.github.com/repos/<github_user>/weblogic-azure/dispatches -H 'Accept: application/vnd.github.everest-preview+json' -H 'Authorization: token <personal_access_token>' --data '{"event_type": "aks-integration-test-with-dependency-creation"}'
# curl --verbose -X POST https://api.github.com/repos/<github_user>/weblogic-azure/dispatches -H 'Accept: application/vnd.github.everest-preview+json' -H 'Authorization: token <personal_access_token>' --data '{"event_type": "aks-integration-test-with-dependency-creation", "client_payload": {"gitUserNameForArtifactsLocation": "<github_user>", "testBranchNameForArtifactsLocation": "<branch_name>", "isForDemo": "false"}}'
repository_dispatch:
types: [aks-integration-test-with-dependency-creation]

Expand All @@ -43,8 +43,32 @@ env:

jobs:
preflight:
outputs:
isForDemo: ${{ steps.setup-env-variables-based-on-dispatch-event.outputs.isForDemo }}
gitUserNameForArtifactsLocation: ${{ steps.setup-env-variables-based-on-dispatch-event.outputs.gitUserNameForArtifactsLocation }}
testBranchNameForArtifactsLocation: ${{ steps.setup-env-variables-based-on-dispatch-event.outputs.testBranchNameForArtifactsLocation }}
runs-on: ubuntu-latest
steps:
- name: Setup environment variables
id: setup-env-variables-based-on-dispatch-event
run: |
if [ ${{ github.event_name }} == 'workflow_dispatch' ]; then
isForDemo=${{ github.event.inputs.isForDemo }}
gitUserNameForArtifactsLocation=${{ github.event.inputs.gitUserNameForArtifactsLocation }}
testBranchNameForArtifactsLocation=${{ github.event.inputs.testBranchNameForArtifactsLocation }}
else
isForDemo=${{ github.event.client_payload.isForDemo }}
gitUserNameForArtifactsLocation=${{ github.event.client_payload.gitUserNameForArtifactsLocation }}
testBranchNameForArtifactsLocation=${{ github.event.client_payload.testBranchNameForArtifactsLocation }}
fi
echo "##[set-output name=isForDemo;]${isForDemo}"
echo "##[set-output name=gitUserNameForArtifactsLocation;]${gitUserNameForArtifactsLocation}"
echo "##[set-output name=testBranchNameForArtifactsLocation;]${testBranchNameForArtifactsLocation}"
echo "isForDemo=${isForDemo}" >> $GITHUB_ENV
echo "gitUserNameForArtifactsLocation=${gitUserNameForArtifactsLocation}" >> $GITHUB_ENV
echo "testBranchNameForArtifactsLocation=${testBranchNameForArtifactsLocation}" >> $GITHUB_ENV
- name: Set up JDK 1.8
uses: actions/setup-java@v1
with:
Expand All @@ -68,7 +92,7 @@ jobs:
with:
path: weblogic-azure
- name: Build and test weblogic-azure/weblogic-azure-aks
run: mvn -Pbicep -Ddev -Passembly clean install --file weblogic-azure/weblogic-azure-aks/pom.xml
run: mvn -Pbicep -Passembly clean install --file weblogic-azure/weblogic-azure-aks/pom.xml
- name: Generate artifact file name and path
id: artifact_file
run: |
Expand Down Expand Up @@ -173,7 +197,7 @@ jobs:
inlineScript: |
az storage blob upload --account-name ${{ env.storageAccountName }} --container-name ${{ env.storageContainerName }} --file cargotracker/target/cargo-tracker.war --name cargo-tracker.war
deploy-wls-on-aks:
needs: [deploy-storage-account, deploy-db]
needs: [deploy-storage-account, deploy-db, preflight]
runs-on: ubuntu-latest
steps:
- name: Checkout weblogic-azure
Expand Down Expand Up @@ -231,8 +255,8 @@ jobs:
s/#appPackageUrls#/${cargoTrackerBlobUrl}/g; \
s/#servicePrincipal#/${servicePrincipal}/g; \
s/#wdtRuntimePassword#/${wdtRuntimePassword}/g; \
s/#testbranchName#/${{ github.event.inputs.testBranchNameForArtifactsLocation }}/g; \
s/#gitUserName#/${{ github.event.inputs.gitUserNameForArtifactsLocation }}/g; \
s/#testbranchName#/${{ needs.preflight.outputs.testBranchNameForArtifactsLocation }}/g; \
s/#gitUserName#/${{ needs.preflight.outputs.gitUserNameForArtifactsLocation }}/g; \
s/#dbPassword#/${dbPassword}/g; \
s/#dbUser#/${dbAdminUser}@${dbName}/g; \
s/#dsConnectionURL#/jdbc:postgresql:\/\/${dbName}.postgres.database.azure.com:5432\/postgres/g" \
Expand Down Expand Up @@ -271,20 +295,17 @@ jobs:
echo "Cargo Tracker is accessible"
fi
- name: Install kubectl
if: ${{ github.event.inputs.isForDemo == 'true' }}
run: |
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
curl -LO "https://dl.k8s.io/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl.sha256"
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
kubectl version --client
- name: Connect to AKS cluster
if: ${{ github.event.inputs.isForDemo == 'true' }}
run: |
echo "connect to cluster"
aksClusterName=$(az resource list --resource-group ${{ env.resourceGroupForWlsAks }} --query "[?type=='Microsoft.ContainerService/managedClusters'].name|[0]" -o tsv)
az aks get-credentials --resource-group ${{ env.resourceGroupForWlsAks }} --name $aksClusterName
- name: Generate&Apply configmap
if: ${{ github.event.inputs.isForDemo == 'true' }}
run: |
wlsConfigmapName=sample-domain1-wdt-config-map
wlsConfigmapJson=cargo-tracker-db.json
Expand Down Expand Up @@ -320,8 +341,8 @@ jobs:
--type=json \
'-p=[{"op": "replace", "path": "/spec/restartVersion", "value": "'${restartVersion}'" }, {"op": "add", "path": "/spec/configuration/model/configMap", "value": "'${wlsConfigmapName}'" }]'
cleanup:
needs: deploy-wls-on-aks
if: ${{ github.event.inputs.isForDemo == 'false' }}
needs: [deploy-wls-on-aks, preflight]
if: ${{ needs.preflight.outputs.isForDemo == 'false' }}
runs-on: ubuntu-latest
steps:
- uses: azure/login@v1
Expand Down
Loading

0 comments on commit ed802ea

Please sign in to comment.