Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changed XMC DevOps process to use Promote #473

Merged
merged 2 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
8 changes: 7 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 @@ -44,4 +49,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'
robearlam marked this conversation as resolved.
Show resolved Hide resolved
- 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"
Loading