Skip to content

Commit

Permalink
chore(cd): Adjust deployment rules for target environments
Browse files Browse the repository at this point in the history
  • Loading branch information
alepefe committed Dec 11, 2024
1 parent 5086683 commit 24ca641
Showing 1 changed file with 31 additions and 32 deletions.
63 changes: 31 additions & 32 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ on:
- 'package.json'

jobs:

set_environment_name:
name: Set Environment
runs-on: ubuntu-latest
Expand All @@ -26,28 +25,46 @@ jobs:
- id: set_env
run: echo "env_name=${{ github.ref_name == 'main' && 'production' || github.ref_name }}" >> $GITHUB_OUTPUT


build_client:
needs: [ set_environment_name ]
environment:
name: ${{ needs.set_environment_name.outputs.env_name }}
trigger_build:
runs-on: ubuntu-latest
name: Build Client image and push to Amazon ECR
outputs:
build_client: ${{ steps.changes.outputs.client == 'true' || github.ref_name == 'staging' || github.ref_name == 'main' }}
build_api: ${{ steps.changes.outputs.api == 'true' || github.ref_name == 'staging' || github.ref_name == 'main' }}
build_backoffice: ${{ steps.changes.outputs.backoffice == 'true' || github.ref_name == 'staging' || github.ref_name == 'main' }}
steps:
- name: Checkout code
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: client-changes
- name: Detect changes in client and API paths
uses: dorny/paths-filter@v3
id: changes
with:
filters: |
client:
- '.github/workflows/**'
- 'shared/**'
- 'client/**'
api:
- '.github/workflows/**'
shared:
- 'shared/**'
- 'api/**'
backoffice:
- '.github/workflows/**'
- 'shared/**'
- 'backoffice/**'
build_client:
needs: [ set_environment, trigger_build ]
if: ${{ github.event_name == 'workflow_dispatch' || needs.trigger_build.outputs.build_client == 'true' }}
environment:
name: ${{ needs.set_environment_name.outputs.env_name }}
runs-on: ubuntu-latest
name: Build Client image and push to Amazon ECR
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Configure AWS credentials
if: ${{ github.event_name == 'workflow_dispatch' || steps.client-changes.outputs.client == 'true' }}
uses: aws-actions/configure-aws-credentials@v4
Expand Down Expand Up @@ -86,7 +103,8 @@ jobs:
${{ steps.login-ecr.outputs.registry }}/${{ secrets.CLIENT_REPOSITORY_NAME }}:${{ needs.set_environment_name.outputs.env_name }}
build_api:
needs: [ set_environment_name ]
needs: [ set_environment, trigger_build ]
if: ${{ github.event_name == 'workflow_dispatch' || needs.trigger_build.outputs.build_api == 'true' }}
environment:
name: ${{ needs.set_environment_name.outputs.env_name }}
runs-on: ubuntu-latest
Expand All @@ -95,16 +113,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: api-changes
with:
filters: |
api:
- 'api/**'
- '.github/workflows/**'
shared:
- 'shared/**'
- name: Configure AWS credentials
if: ${{ github.event_name == 'workflow_dispatch' || steps.api-changes.outputs.api == 'true' }}
uses: aws-actions/configure-aws-credentials@v4
Expand Down Expand Up @@ -158,7 +166,8 @@ jobs:
${{ steps.login-ecr.outputs.registry }}/${{ secrets.API_REPOSITORY_NAME }}:${{ needs.set_environment_name.outputs.env_name }}
build_backoffice:
needs: [ set_environment_name ]
needs: [ set_environment, trigger_build ]
if: ${{ github.event_name == 'workflow_dispatch' || needs.trigger_build.outputs.build_backoffice == 'true' }}
environment:
name: ${{ needs.set_environment_name.outputs.env_name }}
runs-on: ubuntu-latest
Expand All @@ -167,16 +176,6 @@ jobs:
- name: Checkout code
uses: actions/checkout@v4

- uses: dorny/paths-filter@v3
id: backoffice-changes
with:
filters: |
backoffice:
- 'backoffice/**'
- '.github/workflows/**'
shared:
- 'shared/**'
- name: Configure AWS credentials
if: ${{ github.event_name == 'workflow_dispatch' || steps.backoffice-changes.outputs.backoffice == 'true' }}
uses: aws-actions/configure-aws-credentials@v4
Expand Down

0 comments on commit 24ca641

Please sign in to comment.