Skip to content

Commit

Permalink
chore(cd): Fix deployment pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
alepefe committed Dec 12, 2024
1 parent 07f4ddc commit d24c832
Showing 1 changed file with 7 additions and 18 deletions.
25 changes: 7 additions & 18 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ on:
paths:
- 'client/**'
- 'api/**'
- 'backoffice/**'
- '.github/workflows/*'
- 'infrastructure/**'
- 'package.json'
Expand All @@ -28,9 +29,9 @@ jobs:
trigger_build:
runs-on: ubuntu-latest
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' }}
build_client: ${{ github.event_name == 'workflow_dispatch' || steps.changes.outputs.client == 'true' || github.ref_name == 'staging' || github.ref_name == 'main' }}
build_api: ${{ github.event_name == 'workflow_dispatch' || steps.changes.outputs.api == 'true' || github.ref_name == 'staging' || github.ref_name == 'main' }}
build_backoffice: ${{ github.event_name == 'workflow_dispatch' || steps.changes.outputs.backoffice == 'true' || github.ref_name == 'staging' || github.ref_name == 'main' }}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -56,7 +57,7 @@ jobs:
build_client:
needs: [ set_environment_name, trigger_build ]
if: ${{ github.event_name == 'workflow_dispatch' || needs.trigger_build.outputs.build_client == 'true' }}
if: ${{ needs.trigger_build.outputs.build_client == 'true' }}
environment:
name: ${{ needs.set_environment_name.outputs.env_name }}
runs-on: ubuntu-latest
Expand All @@ -66,26 +67,22 @@ jobs:
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
with:
aws-access-key-id: ${{ secrets.PIPELINE_USER_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PIPELINE_USER_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
if: ${{ github.event_name == 'workflow_dispatch' || steps.client-changes.outputs.client == 'true' }}
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'

- name: Set up Docker Buildx
if: ${{ github.event_name == 'workflow_dispatch' || steps.client-changes.outputs.client == 'true' }}
uses: docker/setup-buildx-action@v3

- name: Build, tag, and push Client image to Amazon ECR
if: ${{ github.event_name == 'workflow_dispatch' || steps.client-changes.outputs.client == 'true' }}
uses: docker/build-push-action@v6
with:
build-args: |
Expand All @@ -104,7 +101,7 @@ jobs:
build_api:
needs: [ set_environment_name, trigger_build ]
if: ${{ github.event_name == 'workflow_dispatch' || needs.trigger_build.outputs.build_api == 'true' }}
if: ${{ needs.trigger_build.outputs.build_api == 'true' }}
environment:
name: ${{ needs.set_environment_name.outputs.env_name }}
runs-on: ubuntu-latest
Expand All @@ -114,26 +111,22 @@ jobs:
uses: actions/checkout@v4

- name: Configure AWS credentials
if: ${{ github.event_name == 'workflow_dispatch' || steps.api-changes.outputs.api == 'true' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.PIPELINE_USER_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PIPELINE_USER_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
if: ${{ github.event_name == 'workflow_dispatch' || steps.api-changes.outputs.api == 'true' }}
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'

- name: Set up Docker Buildx
if: ${{ github.event_name == 'workflow_dispatch' || steps.api-changes.outputs.api == 'true' }}
uses: docker/setup-buildx-action@v3

- name: Build, tag, and push API image to Amazon ECR
if: ${{ github.event_name == 'workflow_dispatch' || steps.api-changes.outputs.api == 'true' }}
uses: docker/build-push-action@v6
with:
build-args: |
Expand Down Expand Up @@ -167,7 +160,7 @@ jobs:
build_backoffice:
needs: [ set_environment_name, trigger_build ]
if: ${{ github.event_name == 'workflow_dispatch' || needs.trigger_build.outputs.build_backoffice == 'true' }}
if: ${{ needs.trigger_build.outputs.build_backoffice == 'true' }}
environment:
name: ${{ needs.set_environment_name.outputs.env_name }}
runs-on: ubuntu-latest
Expand All @@ -177,26 +170,22 @@ jobs:
uses: actions/checkout@v4

- name: Configure AWS credentials
if: ${{ github.event_name == 'workflow_dispatch' || steps.backoffice-changes.outputs.backoffice == 'true' }}
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.PIPELINE_USER_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.PIPELINE_USER_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}

- name: Login to Amazon ECR
if: ${{ github.event_name == 'workflow_dispatch' || steps.backoffice-changes.outputs.backoffice == 'true' }}
id: login-ecr
uses: aws-actions/amazon-ecr-login@v2
with:
mask-password: 'true'

- name: Set up Docker Buildx
if: ${{ github.event_name == 'workflow_dispatch' || steps.backoffice-changes.outputs.backoffice == 'true' }}
uses: docker/setup-buildx-action@v3

- name: Build, tag, and push Admin image to Amazon ECR
if: ${{ github.event_name == 'workflow_dispatch' || steps.backoffice-changes.outputs.backoffice == 'true' }}
uses: docker/build-push-action@v6
with:
build-args: |
Expand Down

0 comments on commit d24c832

Please sign in to comment.