Skip to content

Commit

Permalink
Merge pull request #473 from Sitecore/230-devops-promote-change
Browse files Browse the repository at this point in the history
Changed XMC DevOps process to use Promote
  • Loading branch information
robearlam authored Jun 27, 2024
2 parents c6f3d86 + ee59a12 commit 19047b3
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/CI-CD_XM_Cloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
Expand Down
9 changes: 8 additions & 1 deletion .github/workflows/deploy_xmCloud.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:
environmentName:
required: true
type: string
outputs:
completedDeploymentId:
value: '${{ jobs.deploy.outputs.completedDeploymentId }}'
secrets:
XM_CLOUD_CLIENT_ID:
required: true
Expand All @@ -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
Expand All @@ -29,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
Expand All @@ -44,4 +50,5 @@ jobs:
echo "Operation Failed."
exit -1
fi
echo "Deployment Completed"
echo "Deployment Completed"
echo "completedDeploymentId=$deploymentId" >> "$GITHUB_OUTPUT"
50 changes: 50 additions & 0 deletions .github/workflows/promote_xmCloud.yml
Original file line number Diff line number Diff line change
@@ -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"

0 comments on commit 19047b3

Please sign in to comment.