Skip to content

Commit

Permalink
New pipe (#54)
Browse files Browse the repository at this point in the history
  • Loading branch information
SMANUM authored Nov 21, 2023
1 parent ea00a10 commit ea6fd4e
Show file tree
Hide file tree
Showing 7 changed files with 490 additions and 118 deletions.
111 changes: 0 additions & 111 deletions .github/workflows/build-deploy.yml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
build:
strategy:
matrix:
environment: [ dev ]
environment: [dev]
name: "build"
runs-on: ubuntu-latest
environment: ${{ matrix.environment }}
Expand Down Expand Up @@ -43,15 +43,15 @@ jobs:

- name: Test and Integration tests
run: |
mvn test -Dquarkus.package.type=native -Dquarkus.application.name=atm-layer-model -Dquarkus.profile=prod
mvn package -Pnative -Dquarkus.application.name=atm-layer-model -Dquarkus.profile=prod
- name: Create Status check based on postman results
id: process-postman
uses: im-open/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
results-file: src/test/resources/integration-test/output/result.json
report-name: 'Postman ${{ github.run_number }}'
report-name: 'Postman build: ${{ github.run_number }}'
create-status-check: true
create-pr-comment: true
update-comment-if-one-exists: true
Expand All @@ -70,13 +70,12 @@ jobs:
name: html-report
path: src/test/resources/integration-test/output/result.html

- name: Build, tag, and push docker image to Amazon ECR
- name: Build docker image
env:
REGISTRY: ${{ steps.login-ecr.outputs.registry }}
REPOSITORY: ${{ vars.DOCKER_IMAGE_NAME}}
IMAGE_TAG: ${{ github.sha }}
DOCKER_IMAGE_TAG: ${{ github.sha }}
run: |
docker build -f src/main/java/it/gov/pagopa/atmlayer/service/model/docker/Dockerfile.native -t $REGISTRY/$REPOSITORY:$IMAGE_TAG . \
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
176 changes: 176 additions & 0 deletions .github/workflows/manual-create-pre-release-from-dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
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
- major

defaults:
run:
shell: bash

permissions: write-all

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: Setup JDK
uses: graalvm/setup-graalvm@v1
with:
java-version: '17'
distribution: 'graalvm'
github-token: ${{ secrets.GITHUB_TOKEN }}

- name: Test and Integration tests
run: |
mvn package -Pnative -Dquarkus.application.name=atm-layer-model -Dquarkus.profile=prod
- name: Create Status check based on postman results
id: process-postman
uses: im-open/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
results-file: src/test/resources/integration-test/output/result.json
report-name: 'Postman create pre-release: ${{ github.run_number }}'
create-status-check: true
create-pr-comment: true
update-comment-if-one-exists: true
ignore-test-failures: true
timezone: 'europe/rome'

- name: Fail if there were errors in the postman tests
if: steps.process-postman.outputs.test-outcome == 'Failed'
run: |
echo "There were postman failures."
exit 1
- name: Upload result.html
uses: actions/upload-artifact@v3
with:
name: html-report
path: src/test/resources/integration-test/output/result.html

- 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
Loading

0 comments on commit ea6fd4e

Please sign in to comment.