generated from pagopa/pagopa-functions-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[SELC - 4959] feat: create CDC module, infra and pipelines (#272)
- Loading branch information
1 parent
88713da
commit 5949517
Showing
48 changed files
with
1,922 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,182 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
environment: | ||
type: string | ||
required: true | ||
tf_environment: | ||
type: string | ||
required: false | ||
|
||
env: | ||
DIR: "./infra/container_apps/onboarding-cdc" | ||
ARM_SUBSCRIPTION_ID: ${{ vars.ARM_SUBSCRIPTION_ID }} | ||
ARM_TENANT_ID: ${{ vars.ARM_TENANT_ID }} | ||
ARM_USE_OIDC: true | ||
ARM_USE_AZUREAD: true | ||
ARM_STORAGE_USE_AZUREAD: true | ||
|
||
jobs: | ||
|
||
build: | ||
name: 'Build Docker image' | ||
runs-on: ubuntu-20.04 | ||
environment: ${{ inputs.environment }}-cd | ||
permissions: | ||
packages: write | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
name: Checkout | ||
|
||
- name: Setup Docker buildx | ||
uses: docker/setup-buildx-action@f95db51fddba0c2d1ec667646a06c2ce06100226 # v3.0.0 | ||
|
||
- name: Login to GitHub Container Registry | ||
uses: docker/login-action@343f7c4344506bcbf9b4de18042ae17996df046d # v3.0.0 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Docker Meta | ||
id: meta | ||
uses: docker/metadata-action@dbef88086f6cef02e264edb7dbf63250c17cef6c # v5.5.0 | ||
with: | ||
images: ghcr.io/${{ github.repository }}-cdc | ||
tags: | | ||
type=raw,value=latest,enable={{is_default_branch}} | ||
type=ref,event=branch | ||
type=sha | ||
labels: | ||
org.opencontainers.image.title=${{ github.repository }}-cdc | ||
org.opencontainers.image.description=SelfCare onboarding-cdc microservice | ||
org.opencontainers.image.authors=PagoPA | ||
org.opencontainers.image.url=github.com/pagopa/${{ github.repository }} | ||
org.opencontainers.image.source=https://github.com/${{ github.repository }} | ||
|
||
- name: Build and Push Image | ||
uses: docker/build-push-action@4a13e500e55cf31b7a5d59a38ab2040ab0f42f56 # v5.1.0 | ||
with: | ||
context: . | ||
file: ./apps/onboarding-cdc/Dockerfile | ||
push: true | ||
tags: ${{ steps.meta.outputs.tags }} | ||
labels: ${{ steps.meta.outputs.labels }} | ||
cache-from: type=gha | ||
cache-to: type=gha,mode=min | ||
build-args: | | ||
REPO_ID=selfcare-github | ||
REPO_USERNAME=${{ github.actor }} | ||
REPO_PASSWORD=${{ secrets.GITHUB_TOKEN }} | ||
tf_plan: | ||
name: 'Terraform Plan' | ||
runs-on: ubuntu-20.04 | ||
environment: ${{ inputs.environment }}-ci | ||
permissions: | ||
id-token: write | ||
contents: read | ||
outputs: | ||
terraform_version: ${{ steps.set-terraform-version.outputs.terraform_version}} | ||
image_tag: ${{ steps.setsha.outputs.short_sha }} | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
name: Checkout | ||
|
||
- name: Set Short Git Commit SHA | ||
id: setsha | ||
run: | | ||
calculatedSha=$(git rev-parse --short ${{ github.sha }}) | ||
echo "short_sha=sha-$calculatedSha" >> $GITHUB_OUTPUT | ||
- name: Set Terraform Version | ||
id: set-terraform-version | ||
run: | | ||
echo "terraform_version=$(cat .terraform-version)" >> $GITHUB_OUTPUT | ||
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0 | ||
name: Setup Terraform | ||
with: | ||
terraform_version: ${{ steps.set-terraform-version.outputs.terraform_version}} | ||
|
||
- name: Terraform Plan | ||
uses: pagopa/terraform-preapply-azure-action@54ded8cda3437c3f6a9f46baf69cb321ce82f5cd | ||
with: | ||
client_id: ${{ secrets.ARM_CLIENT_ID }} | ||
tenant_id: ${{ vars.ARM_TENANT_ID }} | ||
subscription_id: ${{ vars.ARM_SUBSCRIPTION_ID }} | ||
dir: ${{ env.DIR }} | ||
azure_environment: ${{ inputs.tf_environment }} | ||
env: | ||
TF_VAR_image_tag: ${{ steps.setsha.outputs.short_sha }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: "Upload Terraform Plan as Artifact" | ||
uses: actions/upload-artifact@694cdabd8bdb0f10b2cea11669e1bf5453eed0a6 # v4.2.0 | ||
with: | ||
name: tfplan | ||
path: ${{ env.DIR }}/tfplan-${{ inputs.tf_environment }}-${{ github.sha }} | ||
if-no-files-found: error | ||
retention-days: 14 | ||
|
||
release: | ||
name: 'Release' | ||
runs-on: ubuntu-20.04 | ||
needs: [build, tf_plan] | ||
environment: ${{ inputs.environment }}-cd | ||
permissions: | ||
id-token: write | ||
contents: read | ||
env: | ||
ARM_CLIENT_ID: ${{ secrets.ARM_CLIENT_ID }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
steps: | ||
|
||
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 | ||
name: Checkout | ||
|
||
- name: Azure Login | ||
uses: azure/login@cb79c773a3cfa27f31f25eb3f677781210c9ce3d # v1.6.1 | ||
with: | ||
client-id: ${{ secrets.ARM_CLIENT_ID }} | ||
tenant-id: ${{ vars.ARM_TENANT_ID }} | ||
subscription-id: ${{ vars.ARM_SUBSCRIPTION_ID }} | ||
|
||
- name: Download Terraform Plan as Artifact | ||
uses: actions/download-artifact@6b208ae046db98c579e8a3aa621ab581ff575935 # v4.1.1 | ||
with: | ||
name: tfplan | ||
path: ${{ env.DIR }} | ||
|
||
- name: Retrieve Terraform Modules from Cache | ||
id: cache-terraform-modules | ||
uses: actions/cache@13aacd865c20de90d75de3b17ebe84f7a17d57d2 # v4.0.0 | ||
with: | ||
path: ${{ env.DIR }}/.terraform | ||
key: terraform-${{ env.DIR }}-${{ github.sha }} | ||
restore-keys: | | ||
terraform-${{ env.DIR }} | ||
- uses: hashicorp/setup-terraform@a1502cd9e758c50496cc9ac5308c4843bcd56d36 # v3.0.0 | ||
name: Setup Terraform | ||
with: | ||
terraform_version: ${{ needs.tf_plan.outputs.terraform_version }} | ||
|
||
- name: Terraform Init | ||
shell: bash | ||
working-directory: ${{ env.DIR }} | ||
run: | | ||
bash ./terraform.sh init ${{ inputs.tf_environment }} | ||
- name: Terraform Apply | ||
shell: bash | ||
working-directory: ${{ env.DIR }} | ||
run: | | ||
terraform apply -lock-timeout=3000s -auto-approve -input=false tfplan-${{ inputs.tf_environment }}-${{ github.sha }} | ||
env: | ||
TF_VAR_image_tag: ${{ needs.tf_plan.outputs.image_tag }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
name: Code Review onboarding-cdc | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
pull_request: | ||
branches: | ||
- main | ||
- releases/** | ||
types: | ||
- opened | ||
- edited | ||
- synchronize | ||
- reopened | ||
- ready_for_review | ||
paths: | ||
- 'apps/onboarding-cdc/**' | ||
- '.github/workflows/pr_cdc.yml' | ||
- '.github/workflows/call_code_review.yml' | ||
|
||
jobs: | ||
code_review: | ||
uses: ./.github/workflows/call_code_review.yml | ||
name: Onboarding cdc Code Review | ||
secrets: inherit | ||
with: | ||
pr_number: ${{ github.event.pull_request.number }} | ||
source_branch: ${{ github.head_ref }} | ||
target_branch: ${{ github.base_ref }} | ||
sonar_key: 'pagopa_selfcare-onboarding' | ||
module: 'onboarding-cdc' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Deploy onboarding-cdc | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- releases/* | ||
paths: | ||
- "apps/onboarding-cdc/**" | ||
- "infra/container_apps/onboarding-cdc/**" | ||
- "apps/pom.xml" | ||
- "pom.xml" | ||
|
||
workflow_dispatch: | ||
inputs: | ||
env: | ||
type: choice | ||
description: Environment | ||
options: | ||
- dev | ||
- uat | ||
- prod | ||
|
||
jobs: | ||
|
||
release_dev: | ||
uses: ./.github/workflows/call_release_cdc.yml | ||
name: '[Dev] Onboarding-cdc ms Release' | ||
if: ${{ (startsWith(github.ref_name, 'releases/') != true && inputs.env == null) || inputs.env == 'dev' }} | ||
secrets: inherit | ||
with: | ||
environment: dev | ||
tf_environment: dev | ||
|
||
release_uat: | ||
uses: ./.github/workflows/call_release_cdc.yml | ||
name: '[UAT] Onboarding-cdc ms Release' | ||
if: ${{ (startsWith(github.ref_name, 'releases/') == true && inputs.env == null) || inputs.env == 'uat' }} | ||
secrets: inherit | ||
with: | ||
environment: uat | ||
tf_environment: uat | ||
|
||
release_prod: | ||
uses: ./.github/workflows/call_release_cdc.yml | ||
name: '[Prod] Onboarding-cdc ms Release' | ||
if: ${{ inputs.env == 'prod' }} | ||
secrets: inherit | ||
with: | ||
environment: prod | ||
tf_environment: prod |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
name: Deploy PNPG onboarding-cdc | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- releases/* | ||
paths: | ||
- "apps/onboarding-cdc/**" | ||
- "infra/container_apps/onboarding-cdc/**" | ||
- "apps/pom.xml" | ||
- "pom.xml" | ||
|
||
workflow_dispatch: | ||
inputs: | ||
env: | ||
type: choice | ||
description: Environment | ||
options: | ||
- dev | ||
- uat | ||
- prod | ||
|
||
jobs: | ||
|
||
release_dev: | ||
uses: ./.github/workflows/call_release_cdc.yml | ||
name: '[Dev] PNPG Onboarding-cdc ms Release' | ||
if: ${{ (startsWith(github.ref_name, 'releases/') != true && inputs.env == null) || inputs.env == 'dev' }} | ||
secrets: inherit | ||
with: | ||
environment: dev | ||
tf_environment: dev-pnpg | ||
|
||
release_uat: | ||
uses: ./.github/workflows/call_release_cdc.yml | ||
name: '[UAT] PNPG Onboarding-cdc ms Release' | ||
if: ${{ (startsWith(github.ref_name, 'releases/') == true && inputs.env == null) || inputs.env == 'uat' }} | ||
secrets: inherit | ||
with: | ||
environment: uat | ||
tf_environment: uat-pnpg | ||
|
||
release_prod: | ||
uses: ./.github/workflows/call_release_cdc.yml | ||
name: '[Prod] PNPG Onboarding-cdc ms Release' | ||
if: ${{ inputs.env == 'prod' }} | ||
secrets: inherit | ||
with: | ||
environment: prod | ||
tf_environment: prod-pnpg |
Oops, something went wrong.