[ZARS-669][ADD]node 22 (#32) #212
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: Pipeline | |
on: | |
push: | |
pull_request: | |
env: | |
containerRegistry: container-registry.cr.de-fra.ionos.com | |
imageName: fdpg-api | |
isMain: ${{ github.ref == 'refs/heads/main' }} | |
isDev: ${{ github.ref == 'refs/heads/dev' }} | |
nodeVersion: '22.12.0' | |
jobs: | |
qualitiy_gate: | |
name: 'Qualitiy Gate' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: 'Setup Node' | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{env.nodeVersion}} | |
cache: yarn | |
- name: 'Installing Modules' | |
run: yarn install | |
- name: 'Jest Unit Testing' | |
run: yarn test | |
- name: 'Publish Test Results' | |
uses: mikepenz/action-junit-report@v3 | |
if: success() || failure() # always run even if the previous step fails | |
with: | |
report_paths: '**/reports/junit.xml' | |
fail_on_failure: true | |
- name: 'Publish Code Coverage' | |
uses: 5monkeys/cobertura-action@master | |
if: ${{github.event_name == 'pull_request' }} | |
with: | |
path: '**/reports/coverage/cobertura-coverage.xml' | |
minimum_coverage: 75 | |
fail_below_threshold: false | |
only_changed_files: true | |
build_container_image: | |
name: 'Build Container Image' | |
runs-on: ubuntu-latest | |
needs: qualitiy_gate | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: set npmVersionString variable | |
run: echo "npmVersionString="$(node -p "require('./package.json').version") >> "$GITHUB_ENV" | |
- name: set pipeDate variable | |
run: echo "pipeDate=$(date +%Y%m%d)" >> "$GITHUB_ENV" | |
- name: set pipeTime variable | |
run: echo "pipeTime=$(date +%H%M%S)" >> "$GITHUB_ENV" | |
- name: set buildNumberOfDate variable | |
# Github does not support resetting counters => buildNumberOfDate will never be reset to 1, always increases | |
run: echo "buildNumberOfDate=${{github.run_number}}" >> "$GITHUB_ENV" | |
- name: set variables for main | |
if: ${{env.isMain == 'true'}} | |
run: echo "imageTag=${{env.npmVersionString}}_${{env.pipeDate}}_${{env.buildNumberOfDate}}" >> "$GITHUB_ENV" | |
- name: set variables for dev | |
if: ${{env.isDev == 'true'}} | |
run: echo "imageTag=latest" >> "$GITHUB_ENV" | |
- name: set variables when neither main nor dev | |
if: ${{env.isDev == 'false' && env.isMain == 'false'}} | |
run: echo "imageTag=test-latest" >> "$GITHUB_ENV" | |
- name: Login to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
registry: ${{ env.containerRegistry }} | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v4 | |
with: | |
push: ${{env.isMain == 'true' || env.isDev == 'true' }} | |
tags: ${{env.containerRegistry}}/fdpg/${{env.imageName}}:${{env.imageTag}} | |
labels: BUILD_DATE=${{env.pipeDate}} | |
BUILD_TIME=${{env.pipeTime}} | |
BUILD_NO_OF_DATE=${{env.buildNumberOfDate}} | |
SOURCE_BRANCH=${{github.ref}} | |
build-args: | | |
SOFTWARE_VERSION=${{github.ref}} |