Skip to content

Commit

Permalink
fix conditional workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
and-mora committed Nov 18, 2024
1 parent 16afd5f commit 6e532b9
Showing 1 changed file with 30 additions and 19 deletions.
49 changes: 30 additions & 19 deletions .github/workflows/post-merge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,11 @@ jobs:
environment: cstar-d-weu-rtp

permissions:
id-token: write # Get OIDC token to authenticate to Azure.
packages: write # Push container imaged to GHCR.
contents: write # Create a new release.

outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_version: ${{ steps.semantic.outputs.new_release_version }}
digest: ${{ steps.stable_image.outputs.digest }}

steps:
#
Expand Down Expand Up @@ -56,13 +53,33 @@ jobs:
@semantic-release/git@10.0.1 # 3e934d45f97fd07a63617c0fc098c9ed3e67d97a
dry_run: true

dev_deployment:
needs: post_merge
if: needs.post_merge.outputs.new_release_published == 'true'
runs-on: ubuntu-22.04
environment: cstar-d-weu-rtp

permissions:
id-token: write # Get OIDC token to authenticate to Azure.
packages: write # Push container imaged to GHCR.
contents: write # Create a new release.

outputs:
digest: ${{ steps.stable-image.outputs.digest }}

steps:
#
# Checkout the source code.
#
- name: Checkout the source code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # 4.2.2

#
# RELEASE CANDIDATE - Update of gradle.properties with the RC new version.
#
- name: RELEASE CANDIDATE - Update of gradle.properties with the new version
if: steps.semantic.outputs.new_release_published == 'true'
run: |
sed -i -e "s/version=.*/version=${{ steps.semantic.outputs.new_release_version }}-RC/g" gradle.properties
sed -i -e "s/version=.*/version=${{ needs.post_merge.outputs.new_version }}-RC/g" gradle.properties
# todo sonar
#
Expand All @@ -89,15 +106,14 @@ jobs:
context: .
file: src/main/docker/Dockerfile
platforms: linux/amd64
tags: ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ steps.semantic.outputs.new_release_version }}-RC
tags: ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ needs.post_merge.outputs.new_version }}-RC
secrets: |
"gh_token=${{ secrets.GIT_PAT }}"
#
# Setup Terraform
#
- name: Setup Terraform
if: steps.semantic.outputs.new_release_published == 'true'
uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3.1.2
with:
terraform_version: 1.9.7
Expand All @@ -106,7 +122,6 @@ jobs:
# RELEASE CANDIDATE - Update Container App.
#
- name: RELEASE CANDIDATE - Update Container App
if: steps.semantic.outputs.new_release_published == 'true'
shell: bash
working-directory: src/main/terraform
env:
Expand All @@ -115,7 +130,7 @@ jobs:
ARM_TENANT_ID: "${{ secrets.AZURE_TENANT_ID }}"
run: |
terraform init -backend-config="env/dev/backend.tfvars" -reconfigure
terraform apply -var-file="env/dev/terraform.tfvars" -var="rtp_activator_image=ghcr.io/${{ github.repository }}:${{ steps.semantic.outputs.new_release_version }}-RC@${{ steps.rc-image.outputs.digest }}" -auto-approve -lock-timeout=300s
terraform apply -var-file="env/dev/terraform.tfvars" -var="rtp_activator_image=ghcr.io/${{ github.repository }}:${{ needs.post_merge.outputs.new_version }}-RC@${{ steps.rc-image.outputs.digest }}" -auto-approve -lock-timeout=300s
# #
# # Install Newman.
Expand All @@ -141,20 +156,18 @@ jobs:
# STABLE - Update of gradle.properties with the new version.
#
- name: STABLE - Update of gradle.properties with the new version
if: steps.semantic.outputs.new_release_published == 'true'
run: |
sed -i -e "s/version=.*/version=${{ steps.semantic.outputs.new_release_version }}/g" gradle.properties
sed -i -e "s/version=.*/version=${{ needs.post_merge.outputs.new_version }}/g" gradle.properties
git config user.name "GitHub Workflow"
git config user.email "<>"
git add gradle.properties
git commit -m "Updated with new version ${{ steps.semantic.outputs.new_release_version }}"
git commit -m "Updated with new version ${{ needs.post_merge.outputs.new_version }}"
git push origin main
#
# Calculation of the new version (again) with tagging + releasing + etc.
#
- name: Calculation of the new version (w/o dry_run) and put tag
if: steps.semantic.outputs.new_release_published == 'true'
uses: cycjimmy/semantic-release-action@b1b432f13acb7768e0c8efdec416d363a57546f2 # 4.1.1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down Expand Up @@ -190,15 +203,14 @@ jobs:
context: .
file: src/main/docker/Dockerfile
platforms: linux/amd64
tags: ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ steps.semantic.outputs.new_release_version }}
tags: ghcr.io/${{ github.repository }}:latest, ghcr.io/${{ github.repository }}:${{ needs.post_merge.outputs.new_version }}
secrets: |
"gh_token=${{ secrets.GIT_PAT }}"
#
# STABLE - Update Container App.
#
- name: STABLE - Update Container App
if: steps.semantic.outputs.new_release_published == 'true'
shell: bash
working-directory: src/main/terraform
env:
Expand All @@ -207,11 +219,10 @@ jobs:
ARM_TENANT_ID: "${{ secrets.AZURE_TENANT_ID }}"
run: |
terraform init -backend-config="env/dev/backend.tfvars" -reconfigure
terraform apply -var-file="env/dev/terraform.tfvars" -var="rtp_activator_image=ghcr.io/${{ github.repository }}:${{ steps.semantic.outputs.new_release_version }}@${{ steps.stable_image.outputs.digest }}" -auto-approve -lock-timeout=300s
terraform apply -var-file="env/dev/terraform.tfvars" -var="rtp_activator_image=ghcr.io/${{ github.repository }}:${{ needs.post_merge.outputs.new_version }}@${{ steps.stable-image.outputs.digest }}" -auto-approve -lock-timeout=300s
uat_deployment:
needs: post_merge
needs: [ post_merge, dev_deployment]

if: needs.post_merge.outputs.new_release_published == 'true'

Expand Down Expand Up @@ -249,4 +260,4 @@ jobs:
ARM_TENANT_ID: "${{ secrets.AZURE_TENANT_ID }}"
run: |
terraform init -backend-config="env/uat/backend.tfvars" -reconfigure
terraform apply -var-file="env/uat/terraform.tfvars" -var="rtp_activator_image=ghcr.io/${{ github.repository }}:${{ needs.post_merge.outputs.new_version }}@${{ needs.post_merge.outputs.digest }}" -auto-approve -lock-timeout=300s
terraform apply -var-file="env/uat/terraform.tfvars" -var="rtp_activator_image=ghcr.io/${{ github.repository }}:${{ needs.post_merge.outputs.new_version }}@${{ needs.dev_deployment.outputs.digest }}" -auto-approve -lock-timeout=300s

0 comments on commit 6e532b9

Please sign in to comment.