From 78c176a100f9d59d484eaa2b3e43fad7aaaca2c6 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Tue, 25 Jun 2024 14:22:31 +1000 Subject: [PATCH 1/2] Changed XMC DevOps process to promote to Prod, instead of running another build --- .github/workflows/CI-CD_XM_Cloud.yml | 5 +-- .github/workflows/deploy_xmCloud.yml | 8 ++++- .github/workflows/promote_xmCloud.yml | 50 +++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 .github/workflows/promote_xmCloud.yml diff --git a/.github/workflows/CI-CD_XM_Cloud.yml b/.github/workflows/CI-CD_XM_Cloud.yml index 19aae2925..9bbbc8f18 100644 --- a/.github/workflows/CI-CD_XM_Cloud.yml +++ b/.github/workflows/CI-CD_XM_Cloud.yml @@ -42,12 +42,13 @@ jobs: XM_CLOUD_CLIENT_SECRET: ${{ secrets.XM_CLOUD_CLIENT_SECRET }} XM_CLOUD_ENVIRONMENT_ID: ${{ secrets.STAGING_XM_CLOUD_ENVIRONMENT_ID }} - deploy-prod: + promote-to-prod: if: github.ref == 'refs/heads/main' needs: deploy-staging - uses: ./.github/workflows/deploy_xmCloud.yml + uses: ./.github/workflows/promote_xmCloud.yml with: environmentName: Production + deploymentId: ${{ needs.deploy-staging.outputs.completedDeploymentId }} secrets: XM_CLOUD_CLIENT_ID: ${{ secrets.XM_CLOUD_CLIENT_ID }} XM_CLOUD_CLIENT_SECRET: ${{ secrets.XM_CLOUD_CLIENT_SECRET }} diff --git a/.github/workflows/deploy_xmCloud.yml b/.github/workflows/deploy_xmCloud.yml index eb21d26b0..578a221fa 100644 --- a/.github/workflows/deploy_xmCloud.yml +++ b/.github/workflows/deploy_xmCloud.yml @@ -6,6 +6,9 @@ on: environmentName: required: true type: string + outputs: + completedDeploymentId: + value: '${{ jobs.deploy.outputs.completedDeploymentId }}' secrets: XM_CLOUD_CLIENT_ID: required: true @@ -19,6 +22,8 @@ jobs: deploy: name: Deploy the XM Cloud ${{ inputs.environmentName }} Site runs-on: ubuntu-latest + outputs: + completedDeploymentId: ${{ steps.run-deployment.outputs.completedDeploymentId }} steps: - uses: actions/checkout@v3 - uses: actions/setup-dotnet@v2 @@ -44,4 +49,5 @@ jobs: echo "Operation Failed." exit -1 fi - echo "Deployment Completed" \ No newline at end of file + echo "Deployment Completed" + echo "completedDeploymentId=$deploymentId" >> "$GITHUB_OUTPUT" \ No newline at end of file diff --git a/.github/workflows/promote_xmCloud.yml b/.github/workflows/promote_xmCloud.yml new file mode 100644 index 000000000..5b21f3e95 --- /dev/null +++ b/.github/workflows/promote_xmCloud.yml @@ -0,0 +1,50 @@ +name: Promote an XM Cloud deployment to a different environment. + +on: + workflow_call: + inputs: + environmentName: + required: true + type: string + deploymentId: + required: true + type: string + secrets: + XM_CLOUD_CLIENT_ID: + required: true + XM_CLOUD_CLIENT_SECRET: + required: true + XM_CLOUD_ENVIRONMENT_ID: + required: true + +jobs: + + deploy: + name: Promoting XM Cloud Deployment ${{ inputs.deploymentId }} to ${{ inputs.environmentName }} Site + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-dotnet@v2 + with: + dotnet-version: '6.0.x' + - run: dotnet tool restore + - run: dotnet sitecore --help + - name: Authenticate CLI with XM Cloud + run: dotnet sitecore cloud login --client-credentials --client-id ${{ secrets.XM_CLOUD_CLIENT_ID }} --client-secret ${{ secrets.XM_CLOUD_CLIENT_SECRET }} --allow-write + - name: Deploy the CM assets to XM Cloud + run: | + result=$(dotnet sitecore cloud environment promote --environment-id ${{ secrets.XM_CLOUD_ENVIRONMENT_ID }} --source-id ${{ inputs.deploymentId }} --json) + echo $result + isTimedOut=$(echo $result | jq ' .IsTimedOut') + isCompleted=$(echo $result | jq ' .IsCompleted') + if [ $isTimedOut = true ] + then + echo "Operation Timed Out." + exit -1 + fi + if ! [ $isCompleted = true ] + then + echo "Operation Failed." + exit -1 + fi + echo "Deployment Completed" \ No newline at end of file From ee59a1222ede7758b50e1d0d3b65a3eac7e33987 Mon Sep 17 00:00:00 2001 From: Rob Earlam Date: Tue, 25 Jun 2024 15:59:12 +1000 Subject: [PATCH 2/2] Added missing id param from deployXMC workflow --- .github/workflows/deploy_xmCloud.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/deploy_xmCloud.yml b/.github/workflows/deploy_xmCloud.yml index 578a221fa..931105d87 100644 --- a/.github/workflows/deploy_xmCloud.yml +++ b/.github/workflows/deploy_xmCloud.yml @@ -34,6 +34,7 @@ jobs: - name: Authenticate CLI with XM Cloud run: dotnet sitecore cloud login --client-credentials --client-id ${{ secrets.XM_CLOUD_CLIENT_ID }} --client-secret ${{ secrets.XM_CLOUD_CLIENT_SECRET }} --allow-write - name: Deploy the CM assets to XM Cloud + id: run-deployment run: | result=$(dotnet sitecore cloud deployment create --environment-id ${{ secrets.XM_CLOUD_ENVIRONMENT_ID }} --upload --json) echo $result