From 6922ea9086d83f4d1a59c94444bfaf123a67dc1a Mon Sep 17 00:00:00 2001 From: Kyriakos Akriotis Date: Thu, 14 Nov 2024 15:13:39 +0000 Subject: [PATCH] added update-helm-charts in staging and prod wf #161 --- .../workflows/build-publish-production.yaml | 39 ++++++++++++++++++- .github/workflows/build-publish-staging.yaml | 37 +++++++++++++++++- docusaurus.config.ts | 2 +- 3 files changed, 73 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build-publish-production.yaml b/.github/workflows/build-publish-production.yaml index 8ed6d3445..4e8eb314b 100644 --- a/.github/workflows/build-publish-production.yaml +++ b/.github/workflows/build-publish-production.yaml @@ -12,7 +12,9 @@ jobs: environment: name: stable runs-on: ubuntu-latest - + outputs: + image_version: ${{ env.IMAGE_SEMVER }} + steps: - name: Checkout uses: actions/checkout@v4 @@ -79,4 +81,37 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - annotations: ${{ steps.meta.outputs.annotations }} \ No newline at end of file + annotations: ${{ steps.meta.outputs.annotations }} + + update-helm-charts: + needs: [build-stable] + environment: stable + runs-on: ubuntu-latest + + steps: + - name: Configure Git User as GitHub Actions Bot + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Checkout + uses: actions/checkout@v4 + with: + repository: "${{ vars.DOCS_NEXT_CHARTS_ORG }}/${{ vars.DOCS_NEXT_CHARTS_REPO }}" + token: ${{ secrets.DOCS_NEXT_CHARTS_TOKEN }} + + - name: Update Charts and Commit Changes + id: update_charts + env: + image: ${{ vars.REGISTRY }}/${{ vars.REGISTRY_ORG }}/${{ vars.IMG_NAME }} + tag: ${{ needs.build-stable.outputs.image_version }} + run: | + # docusaurus + sed -i 's/^version: .*/version: ${{ vars.DOCS_NEXT_CHART_VERSION }}.${{github.run_number}}/' ./charts/docusaurus/Chart.yaml + sed -i 's/^appVersion: .*/appVersion: ${{ env.tag }}/' ./charts/docusaurus/Chart.yaml + sed -i 's/^tag: .*/tag: ${{ env.tag }}/' ./charts/docusaurus/values-prod.yaml + sed -i 's/^image: .*/image: ${{ env.image }}/' ./charts/docusaurus/values-prod.yaml + # commit and push + git commit -am "Automatic commit from GitHub Actions triggered by action #${{github.run_number}}" + git remote set-url origin https://${{ secrets.DOCS_NEXT_CHARTS_TOKEN }}@github.com/${{ vars.DOCS_NEXT_CHARTS_ORG }}/${{ vars.DOCS_NEXT_CHARTS_REPO }}.git + git push origin main diff --git a/.github/workflows/build-publish-staging.yaml b/.github/workflows/build-publish-staging.yaml index 9502c41e6..c9691f7ac 100644 --- a/.github/workflows/build-publish-staging.yaml +++ b/.github/workflows/build-publish-staging.yaml @@ -17,6 +17,8 @@ jobs: environment: name: preview runs-on: ubuntu-latest + outputs: + image_version: ${{ steps.build_image_tag.outputs.image_version }} steps: - name: Checkout @@ -40,7 +42,7 @@ jobs: - name: Build Image Tag id: build_image_tag - run: echo "image_version=${{ steps.date.outputs.today }}.${{github.run_number}}.${{ steps.commit_hash.outputs.short }}" >> $GITHUB_OUTPUT + run: echo "image_version=${{ steps.date.outputs.today }}.${{github.run_number}}.0-${{ steps.commit_hash.outputs.short }}" >> $GITHUB_OUTPUT - name: Build Container Image Metadata id: meta @@ -88,4 +90,35 @@ jobs: push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} - annotations: ${{ steps.meta.outputs.annotations }} \ No newline at end of file + annotations: ${{ steps.meta.outputs.annotations }} + + update-helm-charts: + needs: [build-preview] + environment: preview + runs-on: ubuntu-latest + + steps: + - name: Configure Git User as GitHub Actions Bot + run: | + git config --global user.name 'github-actions[bot]' + git config --global user.email 'github-actions[bot]@users.noreply.github.com' + + - name: Checkout + uses: actions/checkout@v4 + with: + repository: "${{ vars.DOCS_NEXT_CHARTS_ORG }}/${{ vars.DOCS_NEXT_CHARTS_REPO }}" + token: ${{ secrets.DOCS_NEXT_CHARTS_TOKEN }} + + - name: Update Charts and Commit Changes + id: update_charts + env: + image: ${{ vars.REGISTRY }}/${{ vars.REGISTRY_ORG }}/${{ vars.IMG_NAME }} + tag: ${{ needs.build-preview.outputs.image_version }} + run: | + # docusaurus + sed -i 's/^tag: .*/tag: ${{ env.tag }}/' ./charts/docusaurus/values-stg.yaml + sed -i 's/^image: .*/image: ${{ env.image }}/' ./charts/docusaurus/values-stg.yaml + # commit and push + git commit -am "Automatic commit from GitHub Actions triggered by action #${{github.run_number}}" + git remote set-url origin https://${{ secrets.DOCS_NEXT_CHARTS_TOKEN }}@github.com/${{ vars.DOCS_NEXT_CHARTS_ORG }}/${{ vars.DOCS_NEXT_CHARTS_REPO }}.git + git push origin main \ No newline at end of file diff --git a/docusaurus.config.ts b/docusaurus.config.ts index 9e07e1136..69a442433 100644 --- a/docusaurus.config.ts +++ b/docusaurus.config.ts @@ -218,7 +218,7 @@ const config: Config = { ], }, ], - copyright: `© T-Systems International GmbH ${new Date().getFullYear()} (v` + process.env.REACT_APP_VERSION + `)`, + copyright: `© T-Systems International GmbH ${new Date().getFullYear()} (` + process.env.REACT_APP_VERSION + `)`, }, prism: { theme: prismThemes.oneDark,