From 0e8596396001f14ec0af556e4b0d0f690268fbb3 Mon Sep 17 00:00:00 2001 From: Soule BA Date: Thu, 7 Mar 2024 11:32:58 +0100 Subject: [PATCH] updating to have only one pull request with all changes from main Signed-off-by: Soule BA --- .github/workflows/production-promotion.yaml | 34 ++++++--------------- README.md | 5 +-- 2 files changed, 13 insertions(+), 26 deletions(-) diff --git a/.github/workflows/production-promotion.yaml b/.github/workflows/production-promotion.yaml index 05370f3..030c5ba 100644 --- a/.github/workflows/production-promotion.yaml +++ b/.github/workflows/production-promotion.yaml @@ -20,37 +20,23 @@ jobs: github.event.client_payload.severity == 'info' steps: # Checkout main branch. - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: ref: production - #Parse the event metadata to determine the chart version deployed on staging. - - name: Get chart version from staging - id: staging + fetch-depth: 0 + # Commit changes from the main branch. + - name: Commit changes + id: commit run: | - VERSION=$(echo ${{ github.event.client_payload.metadata.revision }} | cut -d '@' -f1) - NAME=$(echo ${{ github.event.client_payload.involvedObject.name }} | cut -d '@' -f1) - NAMESPACE=$(echo ${{ github.event.client_payload.involvedObject.namespace }} | cut -d '@' -f1) - echo VERSION=${VERSION} >> $GITHUB_OUTPUT - echo NAME=${NAME} >> $GITHUB_OUTPUT - echo NAMESPACE=${NAMESPACE} >> $GITHUB_OUTPUT - # Patch the chart version in the production Helm release manifest. - - name: Set chart version in production - id: production - env: - CHART_VERSION: ${{ steps.staging.outputs.version }} - NAME: ${{ steps.staging.outputs.name }} - NAMESPACE: ${{ steps.staging.outputs.namespace }} - run: | - echo "set chart version to ${CHART_VERSION}" - yq e '(select(.spec.chart.spec.version) | .spec.chart.spec.version) = env(CHART_VERSION)' -i ./components/${NAMESPACE}/base/${NAME}.yaml + git pull origin main # Open a Pull Request if an upgraded is needed in production. - name: Open promotion PR uses: peter-evans/create-pull-request@v6 with: - branch: production-promotion-${{ steps.staging.outputs.name }}-${{ steps.staging.outputs.version }} + branch: production-promotion delete-branch: true token: ${{ secrets.GITHUB_TOKEN }} - commit-message: Promote chart ${{ steps.staging.outputs.name }} to version ${{ steps.staging.outputs.version }} - title: Promote chart ${{ steps.staging.outputs.name }} to version ${{ steps.staging.outputs.version }} + commit-message: Promote chart + title: Promote new changes to production body: | - Promote chart ${{ steps.staging.outputs.name }} to version ${{ steps.staging.outputs.version }}. + Promote new changes to production diff --git a/README.md b/README.md index 2f1cf36..efeb170 100644 --- a/README.md +++ b/README.md @@ -103,8 +103,9 @@ Then it will upgrade the Helm releases to the new version to the staging cluster ### Promotion to Production After the HelmReleases are successfully installed or upgraded on the staging cluster, a promotion pipeline -is triggered to promote the changes to the production clusters. It effectively opens pull requests -on the `production` branch with the updated HelmChart versions. +is triggered to promote the changes to the production clusters. It effectively opens a pull request +on the `production` branch with the updated changes from the `main` branch. The pull request will +keep the changes in sync between the `main` and `production` branches as long as the pull request is open. The promotion pipeline is defined in .github/workflows/production-promotion.yaml. The `provider` and `alerts` used to trigger the promotion pipeline are defined in the `staging` directory