Skip to content

Merge pull request #477 from pg-techno123/release-1.2.0.1 #342

Merge pull request #477 from pg-techno123/release-1.2.0.1

Merge pull request #477 from pg-techno123/release-1.2.0.1 #342

Workflow file for this run

name: Maven Package upon a push
on:
push:
branches:
- '!release-branch'
- release-1*
- '!master'
- 1.*
- develop
- MOSIP*
jobs:
maven-build-dsl-packetcreator:
runs-on: ubuntu-latest
env:
SERVICE_LOCATION: mosip-packet-creator
CONFIG_LOCATION: 'src/main/resources/dockersupport/centralized/mosip-packet-creator'
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
ref: ${{ github.ref }}
java-version: 11
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Setup branch and env
run: |
# Strip git ref prefix from version
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ env.BRANCH_NAME }}
- name: Install xmllint
run: |
sudo apt-get update
sudo apt-get install libxml2-utils
- name: Setup the settings file for ossrh server
run: echo "<settings> <servers> <server> <id>ossrh</id> </server> </servers> <profiles> <profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>allow-snapshots</id> <activation><activeByDefault>true</activeByDefault></activation> <repositories> <repository> <id>snapshots-repo</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> <repository> <id>releases-repo</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> </profile> </profiles> </settings> " > $GITHUB_WORKSPACE/settings.xml
- name: Build mosipTestDataProvider with Maven
run: |
cd mosipTestDataProvider
mvn clean install -s $GITHUB_WORKSPACE/settings.xml
- name: Build mosip-packet-creator with Maven
run: |
cd ./${{env.SERVICE_LOCATION}}
mvn clean install -s $GITHUB_WORKSPACE/settings.xml
- name: Ready the springboot artifacts
run: |
cd ./${{env.SERVICE_LOCATION}}
mkdir -p build_files/config
cp $( find -name 'dslrig-packetcreator-*.jar' -type f ) build_files
cp -r ${{env.CONFIG_LOCATION}}/Biometric\ Devices build_files/Biometric\ Devices
#cp -r ${{env.CONFIG_LOCATION}}/config build_files/config
cp -r src/main/resources/application.properties build_files/config/
cp -r ${{env.CONFIG_LOCATION}}/resource build_files/resource
cp -r ${{env.CONFIG_LOCATION}}/application.properties build_files/application.properties
cp -r ./src/main/resources/dockersupport/centralized/mountvolume/profile_resource ./profile_resource
zip -r release.zip build_files/* profile_resource
- name: Upload the springboot jars
uses: actions/upload-artifact@v1
with:
name: release
path: ./${{env.SERVICE_LOCATION}}/release.zip
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,workflow,job # selectable (default: repo,message)
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required
if: failure() # Pick up events even if the job fails or is canceled.
docker-build-dsl-packetcreator:
needs: maven-build-dsl-packetcreator
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets.dev_namespace_docker_hub }}
SERVICE_NAME: dsl-packetcreator
SERVICE_LOCATION: mosip-packet-creator
DOCKER_BUILDKIT: 1
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v1
with:
name: release
path: ./${{env.SERVICE_LOCATION}}
- name: Setup branch name
run: |
# Strip git ref prefix from version
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
echo ${{ env.BRANCH_NAME }}
- name: Get version info from pom
id: getPomVersion
uses: mavrosxristoforos/[email protected]
with:
xml-file: ./${{ env.SERVICE_LOCATION }}/pom.xml
xpath: /*[local-name()="project"]/*[local-name()="version"]
- name: Extract the mosip-packet-creator jar and its dependency configs
run: |
cd ./${{env.SERVICE_LOCATION}}
unzip "release.zip"
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Build image
run: |
cd ./${{env.SERVICE_LOCATION}}
mkdir docker-image-build
cp -r ./build_files ./docker-image-build/build_files
cp -r ./entrypoint.sh ./docker-image-build/entrypoint.sh
cp -r ./profile_resource ./docker-image-build/profile_resource
cp ./Dockerfile ./docker-image-build/Dockerfile
cd docker-image-build
docker build . --file Dockerfile --build-arg SOURCE=mosip --build-arg COMMIT_HASH=$(git rev-parse HEAD) --build-arg COMMIT_ID=$(git rev-parse --short HEAD) --build-arg BUILD_TIME=${{steps.date.outputs.date}} --tag ${{ env.SERVICE_NAME }}
- name: Log into registry
run: echo "${{ secrets.release_docker_hub }}" | docker login -u ${{ secrets.actor_docker_hub }} --password-stdin
- name: Push image
run: |
IMAGE_ID=$NAMESPACE/$SERVICE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo "push version ${{steps.getPomVersion.outputs.info}}"
if [[ $BRANCH_NAME == master ]]; then
VERSION=latest
else
VERSION=$BRANCH_NAME
fi
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $SERVICE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,workflow,job # selectable (default: repo,message)
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEVOPS_WEBHOOK }} # required
if: failure() # Pick up events even if the job fails or is canceled.
maven-build-dsl-orchestrator:
runs-on: ubuntu-latest
env:
SERVICE_LOCATION: mosip-acceptance-tests
ZIP_FILE_NAME: release-orchestrator
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
ref: ${{ github.ref }}
java-version: 11
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Setup branch and env
run: |
# Strip git ref prefix from version
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ env.BRANCH_NAME }}
- name: Install xmllint
run: |
sudo apt-get update
sudo apt-get install libxml2-utils
- name: Setup the settings file for ossrh server
run: echo "<settings> <servers> <server> <id>ossrh</id> </server> </servers> <profiles> <profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>allow-snapshots</id> <activation><activeByDefault>true</activeByDefault></activation> <repositories> <repository> <id>snapshots-repo</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> <repository> <id>releases-repo</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> </profile> </profiles> </settings> " > $GITHUB_WORKSPACE/settings.xml
- name: Build mosip-packet-creator with Maven
run: |
cd ./${{env.SERVICE_LOCATION}}
mvn clean install -s $GITHUB_WORKSPACE/settings.xml
- name: Ready the springboot artifacts
run: |
cd ./${{env.SERVICE_LOCATION}}
mkdir build_files
cp $( find -name 'dslrig-ivv-orchestrator-*-dependencies.jar' -type f ) build_files
cp -r ./ivv-orchestrator/target/classes/config build_files/
cp -r ./ivv-orchestrator/target/classes/local build_files/
cp -r ./ivv-orchestrator/src/main/resources/local/scenarios scenarios
zip -r ${{env.ZIP_FILE_NAME}}.zip build_files/* scenarios/*
- name: Upload the springboot jars
uses: actions/upload-artifact@v1
with:
name: ${{env.ZIP_FILE_NAME}}
path: ./${{env.SERVICE_LOCATION}}/${{env.ZIP_FILE_NAME}}.zip
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,workflow,job # selectable (default: repo,message)
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }} # required
if: failure() # Pick up events even if the job fails or is canceled.
docker-build-dsl-orchestrator:
needs: maven-build-dsl-orchestrator
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets.dev_namespace_docker_hub }}
SERVICE_NAME: dsl-orchestrator
SERVICE_LOCATION: mosip-acceptance-tests/ivv-orchestrator
ZIP_FILE_NAME: release-orchestrator
DOCKER_BUILDKIT: 1
steps:
- uses: actions/checkout@v2
- uses: actions/download-artifact@v1
with:
name: ${{env.ZIP_FILE_NAME}}
path: ./${{env.SERVICE_LOCATION}}
- name: Setup branch name
run: |
# Strip git ref prefix from version
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
echo ${{ env.BRANCH_NAME }}
- name: Get version info from pom
id: getPomVersion
uses: mavrosxristoforos/[email protected]
with:
xml-file: ./mosip-acceptance-tests/pom.xml
xpath: /*[local-name()="project"]/*[local-name()="version"]
- name: Extract the dsl-orchestrator jar and its dependency configs
run: |
cd ./${{env.SERVICE_LOCATION}}
unzip "${{env.ZIP_FILE_NAME}}.zip"
- name: Get current date
id: date
run: echo "::set-output name=date::$(date +'%Y-%m-%d')"
- name: Build image
run: |
cd ./${{env.SERVICE_LOCATION}}
mkdir docker-image-build
cp -r ./build_files ./docker-image-build/build_files
cp -r ./entrypoint.sh ./docker-image-build/entrypoint.sh
cp -r ./scenarios ./docker-image-build/scenarios
cp ./Dockerfile ./docker-image-build/Dockerfile
cd docker-image-build
docker build . --file Dockerfile --build-arg SOURCE=mosip --build-arg COMMIT_HASH=$(git rev-parse HEAD) --build-arg COMMIT_ID=$(git rev-parse --short HEAD) --build-arg BUILD_TIME=${{steps.date.outputs.date}} --tag ${{ env.SERVICE_NAME }}
- name: Log into registry
run: echo "${{ secrets.release_docker_hub }}" | docker login -u ${{ secrets.actor_docker_hub }} --password-stdin
- name: Push image
run: |
IMAGE_ID=$NAMESPACE/$SERVICE_NAME
# Change all uppercase to lowercase
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
echo "push version ${{steps.getPomVersion.outputs.info}}"
if [[ $BRANCH_NAME == master ]]; then
VERSION=latest
else
VERSION=$BRANCH_NAME
fi
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $SERVICE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,workflow,job # selectable (default: repo,message)
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEVOPS_WEBHOOK }} # required
if: failure() # Pick up events even if the job fails or is canceled.
sonar_analysis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
ref: ${{ github.ref }}
java-version: 11
server-id: ossrh # Value of the distributionManagement/repository/id field of the pom.xml
settings-path: ${{ github.workspace }} # location for the settings.xml file
- name: Setup branch and env
run: |
# Strip git ref prefix from version
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
- uses: actions/cache@v1
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-${{ env.BRANCH_NAME }}
- name: Setup the settings file for ossrh server
run: echo "<settings> <servers> <server> <id>ossrh</id> <username>${{secrets.ossrh_user}}</username> <password>${{secrets.ossrh_secret}}</password> </server> </servers> <profiles> <profile> <id>ossrh</id> <activation> <activeByDefault>true</activeByDefault> </activation> <properties> <gpg.executable>gpg2</gpg.executable> <gpg.passphrase>${{secrets.gpg_secret}}</gpg.passphrase> </properties> </profile> <profile> <id>allow-snapshots</id> <activation><activeByDefault>true</activeByDefault></activation> <repositories> <repository> <id>snapshots-repo</id> <url>https://oss.sonatype.org/content/repositories/snapshots</url> <releases><enabled>false</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> <repository> <id>releases-repo</id> <url>https://oss.sonatype.org/service/local/staging/deploy/maven2</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>false</enabled></snapshots> </repository> </repositories> </profile> <profile> <id>sonar</id> <properties> <sonar.sources>.</sonar.sources> <sonar.host.url>https://sonarcloud.io</sonar.host.url> </properties> <activation> <activeByDefault>false</activeByDefault> </activation> </profile> </profiles> </settings>" > $GITHUB_WORKSPACE/settings.xml
- name: Analyze mosip-automation-tests with SonarCloud
run: mvn -B -Dgpg.skip verify sonar:sonar -Dsonar.projectKey=mosip_mosip-dsl-test-rig -Dsonar.organization=${{ secrets.ORG_KEY }} -Dsonar.host.url=https://sonarcloud.io -Dsonar.login=${{ secrets.SONAR_TOKEN }} -s $GITHUB_WORKSPACE/settings.xml
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- uses: 8398a7/action-slack@v3
with:
status: ${{ job.status }}
fields: repo,message,commit,workflow,job # selectable (default: repo,message)
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_DEVOPS_WEBHOOK }} # required
if: failure() # Pick up events even if the job fails or is canceled.