Skip to content

chore: full service feature review (#613) #227

chore: full service feature review (#613)

chore: full service feature review (#613) #227

name: Deploy Inventory Service
on:
push:
paths:
- src/inventory-service/**
branches:
- "main"
pull_request:
paths:
- src/inventory-service/**
branches:
- "main"
types: [opened, synchronize, reopened]
permissions:
id-token: write
contents: read
jobs:
build-docker-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Java 25 for x64
uses: actions/setup-java@v4
with:
java-version: "25"
distribution: "corretto"
architecture: x64
- 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: "us-east-1"
- name: Login to Amazon ECR public
id: login-ecr-public
uses: aws-actions/amazon-ecr-login@v2
with:
registry-type: public
- 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: "us-east-1"
run: |
cd src/inventory-service
make build
- name: Build, tag, and push docker image to Amazon ECR Public
env:
REGISTRY: ${{ steps.login-ecr-public.outputs.registry }}
REGISTRY_ALIAS: k4y9x2e7
REPOSITORY: dd-serverless-sample-app-inventory-java
IMAGE_TAG: ${{ env.sha_short }}
run: |
cd src/inventory-service/inventory-api
docker build -f src/main/docker/Dockerfile -t $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG .
docker push $REGISTRY/$REGISTRY_ALIAS/$REPOSITORY:$IMAGE_TAG
deploy-tf:
runs-on: ubuntu-latest
needs: build-docker-image
concurrency:
group: tf-networked
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Set up Java 25 for x64
uses: actions/setup-java@v4
with:
java-version: "25"
distribution: "corretto"
architecture: x64
- 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 }}
VERSION: ${{ env.sha_short }}
ENV: "dev"
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-west-2"
run: |
cd src/inventory-service
make build
- name: Deploy ephermal environment
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
ENV: ${{ 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/inventory-service
make tf-apply
- name: Sleep for 60 seconds
run: sleep 60s
shell: bash
- name: Integration test ephermal environment
shell: bash
env:
ENV: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
AWS_REGION: "eu-west-2"
run: |
cd src/inventory-service
make integration-test
- name: Destroy ephermal environment
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
ENV: ${{ 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/inventory-service
make tf-destroy
- name: Deploy to dev
if: github.event_name == 'push'
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ 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/inventory-service
make tf-apply
- name: Sleep for 60 seconds
if: github.event_name == 'push'
run: sleep 60s
shell: bash
- name: Integration test dev
if: github.event_name == 'push'
shell: bash
env:
ENV: "dev"
AWS_REGION: "eu-west-2"
run: |
cd src/inventory-service
make integration-test
- name: Destroy dev
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ 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/inventory-service
make tf-destroy
deploy-cdk:
runs-on: ubuntu-latest
needs: build-docker-image
concurrency:
group: cdk-networked
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "20"
- name: Install CDK
run: |
npm install -g aws-cdk
- name: Set up Java 25 for x64
uses: actions/setup-java@v4
with:
java-version: "25"
distribution: "corretto"
architecture: x64
- 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 }}
VERSION: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/inventory-service
make build
- name: Deploy ephermal environment
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
ENV: ${{ env.sha_short }}
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
run: |
cd src/inventory-service
make cdk-deploy
- name: Integration test ephermal environment
shell: bash
env:
ENV: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
AWS_REGION: "eu-west-1"
run: |
cd src/inventory-service
make integration-test
- name: Destroy ephermal environment
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
ENV: ${{ env.sha_short }}
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
run: |
cd src/inventory-service
make cdk-destroy
- name: Deploy to dev
if: github.event_name == 'push'
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
run: |
cd src/inventory-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/inventory-service
make integration-test
- name: Destroy dev
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
run: |
cd src/inventory-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: "20"
- name: Install CDK
run: |
npm install -g aws-cdk
- name: Set up Java 25 for x64
uses: actions/setup-java@v4
with:
java-version: "25"
distribution: "corretto"
architecture: x64
- 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-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 }}
VERSION: ${{ env.sha_short }}
ENV: "prod"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-west-2"
run: |
cd src/inventory-service
make build
- name: Deploy to prod
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
ENV: prod
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
run: |
cd src/inventory-service
make cdk-deploy
- name: Integration test prod
shell: bash
env:
ENV: prod
VERSION: ${{ env.sha_short }}
AWS_REGION: "eu-west-2"
run: |
cd src/inventory-service
make integration-test
deploy-sam:
runs-on: ubuntu-latest
needs: build-docker-image
concurrency:
group: sam-networked
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Set up Node
uses: actions/setup-node@v3
with:
node-version: "22"
- name: Set up Java 25 for x64
uses: actions/setup-java@v4
with:
java-version: "25"
distribution: "corretto"
architecture: x64
- 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 }}
VERSION: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/inventory-service
make build
- name: Deploy to ephermal environment
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
ENV: ${{ env.sha_short }}
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/inventory-service
make sam
- name: Integration test ephermal environment
shell: bash
env:
ENV: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
AWS_REGION: "eu-central-1"
run: |
cd src/inventory-service
make integration-test
- name: Destroy
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
ENV: ${{ env.sha_short }}
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/inventory-service
make sam-destroy
- name: Deploy to dev
if: github.event_name == 'push'
shell: bash
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/inventory-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/inventory-service
make integration-test
- name: Destroy dev
shell: bash
if: always()
env:
COMMIT_HASH: ${{ env.sha_short }}
VERSION: ${{ env.sha_short }}
ENV: "dev"
DD_API_KEY: ${{secrets.DD_API_KEY}}
DD_SITE: "datadoghq.eu"
AWS_REGION: "eu-central-1"
run: |
cd src/inventory-service
make sam-destroy