Skip to content

Manual create pre-release from dev #102

Manual create pre-release from dev

Manual create pre-release from dev #102

name: Manual create pre-release from dev
on:
workflow_dispatch:
inputs:
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: [dev]
name: "manual-create-pre-release"
runs-on: ubuntu-latest
environment: ${{ matrix.environment }}
steps:
- name: Checkout code
uses: actions/checkout@ee0669bd1cc54295c223e0bb666b733df41de1c5 # 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@062b18b96a7aff071d4dc91bc00c4c1a7945b076 # v2
- name: Setup JDK
uses: graalvm/setup-graalvm@2911b2304bee2c2f59b9a67bf45f025a6b6de4b1 # v1
with:
java-version: '21'
distribution: 'graalvm'
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 }}: ${{ 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: Update file pom.xml with the new version
if: steps.semantic-release-dryrun.outputs.new_release_published == 'true'
run: |
mvn versions:set -DnewVersion=${{ steps.semantic-release-dryrun.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 --allow-empty -m "pom.xml updated with new version ${{ steps.semantic-release-dryrun.outputs.new_release_version }}"
git push
- name: Update file Chart.yaml with the new version
if: steps.semantic-release-dryrun.outputs.new_release_published == 'true'
run: |
yq -i ".version = \"v${{ steps.semantic-release-dryrun.outputs.new_release_version }}\"" "helm-chart/Chart.yaml"
git pull
git add "helm-chart/Chart.yaml"
git commit --allow-empty -m "Chart.yaml updated with new version v${{ steps.semantic-release-dryrun.outputs.new_release_version }}"
git push
- name: Test and Integration tests
run: |
mvn test -Dquarkus.package.type=native -Dquarkus.application.name=atm-layer-model -Dquarkus.profile=prod
- name: Create Status check based on postman results
id: process-postman
uses: im-open/process-postman-test-results@4cc90df9ffdd1554366e19e759a15d008bdf3c39 # v2.1.5
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@a8a3f3ad30e3422c9c7b888a15615d19a852ae32 # v3
with:
name: html-report
path: src/test/resources/integration-test/output/result.html
- name: JaCoCo Code Coverage Report
id: jacoco_reporter
uses: PavanMudigonda/jacoco-reporter@76044ebc031589dcbce0bb1048ffee1072a43f97 # v4.9
with:
coverage_results_path: target/jacoco-report/jacoco.xml
coverage_report_name: 'Coverage create pre-release: ${{ github.run_number }}'
coverage_report_title: JaCoCo
github_token: ${{ secrets.GITHUB_TOKEN }}
skip_check_run: false
minimum_coverage: 90
fail_below_threshold: false
publish_only_summary: false
- name: Fail Build if overall coverage is less than 90%
if: steps.jacoco_reporter.outputs.coverage_percentage < 90.0
uses: actions/github-script@d7906e4ad0b1822421a7e6a35d5ca353c962f410 # v6
with:
script: |
core.setFailed('Overall coverage is less than 90%!')
- 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 }}: 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: 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