Manual create pre-release from dev #50
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
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@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 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/[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: JaCoCo Code Coverage Report | |
id: jacoco_reporter | |
uses: PavanMudigonda/[email protected] | |
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@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 }}: ${{ 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 |