Skip to content

fix: skip sam build for pricing service to deploy pre-built artifact … #202

fix: skip sam build for pricing service to deploy pre-built artifact …

fix: skip sam build for pricing service to deploy pre-built artifact … #202

name: Deploy Loyalty Service
on:
push:
paths:
- src/loyalty-point-service/**
branches:
- "main"
pull_request:
paths:
- src/loyalty-point-service/**
branches:
- "main"
types: [opened, synchronize, reopened]
permissions:
id-token: write
contents: read
jobs:
deploy-tf:
runs-on: ubuntu-latest
concurrency:
group: tf-loyalty-service
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "22"
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: "eu-west-2"
- name: Set Commit Hash Environment Variables
shell: bash
run: |
echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
- name: Build
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/loyalty-point-service
make build
- name: Deploy to ephermal environment
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "tf-${{ env.sha_short }}"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-west-2"
TF_STATE_BUCKET_NAME: ${{secrets.TF_STATE_BUCKET_NAME}}
run: |
cd src/loyalty-point-service
make tf-apply
- name: Integration test ephermal environment
shell: bash
env:
ENV: "tf-${{ env.sha_short }}"
AWS_REGION: "eu-west-2"
run: |
cd src/loyalty-point-service
make integration-test
- name: Destroy ephermal environment
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "tf-${{ env.sha_short }}"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-west-2"
TF_STATE_BUCKET_NAME: ${{secrets.TF_STATE_BUCKET_NAME}}
run: |
cd src/loyalty-point-service
make tf-destroy
- name: Deploy to dev
if: github.event_name == 'push'
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-west-2"
TF_STATE_BUCKET_NAME: ${{secrets.TF_STATE_BUCKET_NAME}}
run: |
cd src/loyalty-point-service
make tf-apply
- name: Integration test dev
if: github.event_name == 'push'
shell: bash
env:
ENV: "dev"
AWS_REGION: "eu-west-2"
run: |
cd src/loyalty-point-service
make integration-test
- name: Terraform destroy
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-west-2"
TF_STATE_BUCKET_NAME: ${{secrets.TF_STATE_BUCKET_NAME}}
run: |
cd src/loyalty-point-service
make tf-destroy
deploy-cdk:
runs-on: ubuntu-latest
concurrency:
group: cdk-loyalty-service
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "22"
- name: Install CDK
run: |
npm install -g aws-cdk
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: "eu-west-1"
- name: Set Commit Hash Environment Variables
shell: bash
run: |
echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
- name: Build
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/loyalty-point-service
make build
- name: Deploy to ephermal environment
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "cdk-${{ env.sha_short }}"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
run: |
cd src/loyalty-point-service
make cdk-deploy
- name: Integration test ephermal environment
shell: bash
env:
ENV: "cdk-${{ env.sha_short }}"
AWS_REGION: "eu-west-1"
run: |
cd src/loyalty-point-service
make integration-test
- name: Destroy ephermal environment
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "cdk-${{ env.sha_short }}"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
run: |
cd src/loyalty-point-service
make cdk-destroy
- name: Deploy to dev
if: github.event_name == 'push'
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
run: |
cd src/loyalty-point-service
make cdk-deploy
- name: Integration test dev
if: github.event_name == 'push'
shell: bash
env:
ENV: "dev"
AWS_REGION: "eu-west-1"
run: |
cd src/loyalty-point-service
make integration-test
- name: Destroy dev
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
run: |
cd src/loyalty-point-service
make cdk-destroy
deploy-cdk-prod:
runs-on: ubuntu-latest
needs: [deploy-cdk]
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "22"
- name: Install CDK
run: |
npm install -g aws-cdk
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df
with:
role-to-assume: ${{ secrets.PRODUCTION_AWS_ROLE_ARN }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: "eu-central-1"
- name: Set Commit Hash Environment Variables
shell: bash
run: |
echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
- name: Build
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "prod"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/loyalty-point-service
make build
- name: Deploy to prod
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "prod"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
run: |
cd src/loyalty-point-service
make cdk-deploy
- name: Integration test prod
shell: bash
env:
ENV: "prod"
AWS_REGION: "eu-central-1"
run: |
cd src/loyalty-point-service
make integration-test
deploy-sam:
runs-on: ubuntu-latest
concurrency:
group: sam-loyalty-service
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "22"
- uses: aws-actions/setup-sam@v1
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@b47578312673ae6fa5b5096b330d9fbac3d116df
with:
role-to-assume: ${{ secrets.AWS_ROLE_ARN }}
role-session-name: GitHub_to_AWS_via_FederatedOIDC
aws-region: "eu-central-1"
- name: Set Commit Hash Environment Variables
shell: bash
run: |
echo "sha_short=$(git rev-parse --short "$GITHUB_SHA")" >> "$GITHUB_ENV"
- name: Build
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/loyalty-point-service
make build
- name: Deploy to ephermal environment
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "sam-${{ env.sha_short }}"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/loyalty-point-service
make sam
- name: Integration test ephermal environment
shell: bash
env:
ENV: "sam-${{ env.sha_short }}"
AWS_REGION: "eu-central-1"
run: |
cd src/loyalty-point-service
make integration-test
- name: Destroy ephemeral environment
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "sam-${{ env.sha_short }}"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/loyalty-point-service
make sam-destroy
- name: Deploy to dev
if: github.event_name == 'push'
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/loyalty-point-service
make sam
- name: Integration test dev
if: github.event_name == 'push'
shell: bash
env:
ENV: "dev"
AWS_REGION: "eu-central-1"
run: |
cd src/loyalty-point-service
make integration-test
- name: Destroy dev
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/loyalty-point-service
make sam-destroy