-
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.
- Loading branch information
Showing
5 changed files
with
474 additions
and
0 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,47 @@ | ||
name: Build everytime push or merge | ||
|
||
on: | ||
push: | ||
branches: | ||
- '**' # matches every branch | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
permissions: | ||
id-token: write # This is required for requesting the JWT | ||
contents: write # This is required for actions/checkout | ||
|
||
jobs: | ||
build: | ||
strategy: | ||
matrix: | ||
environment: [dev] | ||
name: "build" | ||
runs-on: ubuntu-latest | ||
environment: ${{ matrix.environment }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 | ||
with: | ||
role-to-assume: ${{ secrets.IAM_ROLE }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Build docker image | ||
env: | ||
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
REPOSITORY: ${{ vars.DOCKER_IMAGE_NAME}} | ||
DOCKER_IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
docker build -f src/main/java/it/gov/pagopa/atmlayer/service/model/docker/Dockerfile.native -t $REGISTRY/$REPOSITORY:$DOCKER_IMAGE_TAG . \ | ||
--build-arg QUARKUS_PROFILE=prod \ | ||
--build-arg APP_NAME=atm-layer-model |
141 changes: 141 additions & 0 deletions
141
.github/workflows/manual-create-pre-release-from-dev.yml
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,141 @@ | ||
name: Manual create pre-release from dev | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
env: | ||
description: 'Environment:' | ||
type: choice | ||
required: true | ||
default: dev | ||
options: | ||
- dev | ||
commit: | ||
description: 'Pre-release type:' | ||
type: choice | ||
required: true | ||
default: feat | ||
options: | ||
- feat | ||
- fix | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
permissions: | ||
id-token: write | ||
contents: write | ||
|
||
jobs: | ||
manual-create-pre-release: | ||
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/dev' | ||
strategy: | ||
matrix: | ||
environment: ["${{ inputs.env }}"] | ||
|
||
name: "manual-create-pre-release" | ||
runs-on: ubuntu-latest | ||
environment: ${{ matrix.environment }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 | ||
with: | ||
role-to-assume: ${{ secrets.IAM_ROLE }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Build docker image | ||
env: | ||
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
REPOSITORY: ${{ vars.DOCKER_IMAGE_NAME}} | ||
DOCKER_IMAGE_TAG: ${{ github.sha }} | ||
run: | | ||
docker build -f src/main/java/it/gov/pagopa/atmlayer/service/model/docker/Dockerfile.native -t $REGISTRY/$REPOSITORY:$DOCKER_IMAGE_TAG . \ | ||
--build-arg QUARKUS_PROFILE=prod \ | ||
--build-arg APP_NAME=atm-layer-model | ||
- name: Commit with "${{ inputs.commit }}:" prefix | ||
run: | | ||
git config user.name "GitHub Action" | ||
git config user.email "[email protected]" | ||
git pull | ||
git add . | ||
git commit --allow-empty -m "${{ inputs.commit }}: ${{ github.sha }}" | ||
git push | ||
- name: Semantic Release | ||
id: semantic-release-dryrun | ||
uses: cycjimmy/semantic-release-action@bdd914ff2423e2792c73475f11e8da603182f32d | ||
with: | ||
dry_run: true | ||
semantic_version: 19 | ||
extra_plugins: | | ||
@semantic-release/[email protected] | ||
@semantic-release/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Commit with "${{ inputs.commit }}:" prefix | ||
run: | | ||
git config user.name "GitHub Action" | ||
git config user.email "[email protected]" | ||
git pull | ||
git add . | ||
git commit --allow-empty -m "${{ inputs.commit }}: docker-image: v${{ steps.semantic-release-dryrun.outputs.new_release_version }}, chart: v${{ steps.semantic-release-dryrun.outputs.new_release_version }}" | ||
git push | ||
- name: Semantic Release | ||
id: semantic-release | ||
uses: cycjimmy/semantic-release-action@bdd914ff2423e2792c73475f11e8da603182f32d | ||
with: | ||
semantic_version: 19 | ||
extra_plugins: | | ||
@semantic-release/[email protected] | ||
@semantic-release/[email protected] | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
||
- name: Update file pom.xml with the new version | ||
if: steps.semantic-release.outputs.new_release_published == 'true' | ||
run: | | ||
mvn versions:set -DnewVersion=${{ steps.semantic-release.outputs.new_release_version }} --no-transfer-progress | ||
git pull | ||
git config user.name "GitHub Action" | ||
git config user.email "[email protected]" | ||
git add pom.xml | ||
git commit -m "pom.xml updated with new version ${{ steps.semantic-release.outputs.new_release_version }}" | ||
git push | ||
- name: Update file Chart.yaml with the new version | ||
if: steps.semantic-release.outputs.new_release_published == 'true' | ||
run: | | ||
yq -i ".version = \"v${{ steps.semantic-release.outputs.new_release_version }}\"" "helm-chart/Chart.yaml" | ||
git pull | ||
git add "helm-chart/Chart.yaml" | ||
git commit -m "Chart.yaml updated with new version v${{ steps.semantic-release.outputs.new_release_version }}" | ||
git push | ||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 | ||
with: | ||
role-to-assume: ${{ secrets.IAM_ROLE }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Tag and push docker image on ECR | ||
if: steps.semantic-release.outputs.new_release_published == 'true' | ||
env: | ||
REGISTRY: ${{ steps.login-ecr.outputs.registry }} | ||
REPOSITORY: ${{ vars.DOCKER_IMAGE_NAME}} | ||
DOCKER_IMAGE_TAG: ${{ github.sha }} | ||
ECR_IMAGE_TAG: "v${{ steps.semantic-release.outputs.new_release_version }}" | ||
run: | | ||
docker tag $REGISTRY/$REPOSITORY:$DOCKER_IMAGE_TAG $REGISTRY/$REPOSITORY:$ECR_IMAGE_TAG | ||
docker push $REGISTRY/$REPOSITORY:$ECR_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,70 @@ | ||
name: Manual deploy release | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
env: | ||
description: 'Environment:' | ||
type: choice | ||
required: true | ||
default: dev | ||
options: | ||
- dev | ||
- uat | ||
- prod | ||
release: | ||
description: 'Which pre-release/release to deploy:' | ||
type: string | ||
required: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
permissions: | ||
id-token: write # This is required for requesting the JWT | ||
contents: write # This is required for actions/checkout | ||
|
||
jobs: | ||
manual-deploy-release: | ||
if: github.event_name == 'workflow_dispatch' | ||
strategy: | ||
matrix: | ||
environment: ["${{ inputs.env }}"] | ||
|
||
name: "manual-deploy-release" | ||
runs-on: ubuntu-latest | ||
environment: ${{ matrix.environment }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Configure AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 | ||
with: | ||
role-to-assume: ${{ secrets.IAM_ROLE }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Login to Amazon ECR | ||
id: login-ecr | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Update Kubernetes Config | ||
run: | | ||
aws eks --region ${{ vars.AWS_REGION }} update-kubeconfig --name pagopa-${{ inputs.env }}-atm-layer-eks | ||
- name: Install Helm | ||
run: | | ||
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 | ||
chmod 700 get_helm.sh | ||
./get_helm.sh | ||
- name: Upgrade Helm Chart | ||
run: | | ||
helm upgrade --install ${{ vars.DOCKER_IMAGE_NAME }} helm-chart/ \ | ||
--namespace pagopa \ | ||
-f helm-chart/environments/values-${{ inputs.env }}.yaml \ | ||
--set image.tag=${{ inputs.release }} \ | ||
--set image.repository=${{ steps.login-ecr.outputs.registry }}/${{ vars.DOCKER_IMAGE_NAME }} \ | ||
--set serviceAccount.annotations."eks\.amazonaws\.com/role-arn"=${{ secrets.SERVICEACCOUNT_IAM_ROLE }} |
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,73 @@ | ||
name: Manual promote release in prod | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
release: | ||
description: 'Which release to promote in prod:' | ||
type: string | ||
required: true | ||
|
||
defaults: | ||
run: | ||
shell: bash | ||
|
||
permissions: | ||
id-token: write # This is required for requesting the JWT | ||
contents: write # This is required for actions/checkout | ||
|
||
jobs: | ||
manual-promote-release-in-prod: | ||
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main' | ||
strategy: | ||
matrix: | ||
environment: [uat] | ||
|
||
name: "manual-promote-release-in-prod" | ||
runs-on: ubuntu-latest | ||
environment: ${{ matrix.environment }} | ||
|
||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v2 | ||
|
||
- name: Configure uat AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 | ||
with: | ||
role-to-assume: ${{ secrets.IAM_ROLE }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Login to uat Amazon ECR | ||
id: login-ecr-uat | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Copy docker image from uat ECR | ||
env: | ||
REGISTRY: ${{ steps.login-ecr-uat.outputs.registry }} | ||
REPOSITORY: ${{ vars.DOCKER_IMAGE_NAME}} | ||
UAT_IMAGE_TAG: ${{ inputs.release }} | ||
run: | | ||
docker pull $REGISTRY/$REPOSITORY:$UAT_IMAGE_TAG | ||
- name: Configure prod AWS Credentials | ||
uses: aws-actions/configure-aws-credentials@67fbcbb121271f7775d2e7715933280b06314838 | ||
with: | ||
role-to-assume: ${{ secrets.PROD_IAM_ROLE }} | ||
aws-region: ${{ vars.AWS_REGION }} | ||
|
||
- name: Login to prod Amazon ECR | ||
id: login-ecr-prod | ||
uses: aws-actions/amazon-ecr-login@v2 | ||
|
||
- name: Push docker image in prod ECR | ||
env: | ||
PROD_REGISTRY: ${{ steps.login-ecr-prod.outputs.registry }} | ||
UAT_REGISTRY: ${{ steps.login-ecr-uat.outputs.registry }} | ||
PROD_REPOSITORY: ${{ vars.PROD_DOCKER_IMAGE_NAME}} | ||
UAT_REPOSITORY: ${{ vars.DOCKER_IMAGE_NAME}} | ||
PROD_IMAGE_TAG: ${{ inputs.release }} | ||
UAT_IMAGE_TAG: ${{ inputs.release }} | ||
run: | | ||
docker tag $UAT_REGISTRY/$UAT_REPOSITORY:$UAT_IMAGE_TAG $PROD_REGISTRY/$PROD_REPOSITORY:$PROD_IMAGE_TAG | ||
docker push $PROD_REGISTRY/$PROD_REPOSITORY:$PROD_IMAGE_TAG | ||
Oops, something went wrong.