Skip to content

Merge pull request #208 from anup-nehe/develop #190

Merge pull request #208 from anup-nehe/develop

Merge pull request #208 from anup-nehe/develop #190

Workflow file for this run

name: Maven Package upon a push
on:
push:
branches:
- '!release-branch'
- release-1*
- master
- 1.0.*
- develop
- 1.1.*
- MOSIP-11719
- 1.2.*
jobs:
build-admin-ui:
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets. dev_namespace_docker_hub }}
SERVICE_NAME: admin-ui
SERVICE_LOCATION: admin-ui
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
- name: npm install
run: cd ${{ env.SERVICE_LOCATION }} && npm install --ignore-scripts
- name: npm build
run: cd ${{ env.SERVICE_LOCATION }} && npm run-script build -- --prod --base-href . --output-path=dist
- 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
- name: setup environment
run: |
# Strip git ref prefix from version
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Build image
run: |
cd "./${{env.SERVICE_LOCATION}}"
# docker build . --file Dockerfile --tag ${{ env.SERVICE_NAME }}
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]')
if [[ $BRANCH_NAME == master ]]; then
VERSION=latest
else
VERSION=$BRANCH_NAME
fi
echo "push version $VERSION"
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $SERVICE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
sonar-analysis:
runs-on: ubuntu-latest
env:
NAMESPACE: ${{ secrets. dev_namespace_docker_hub }}
SERVICE_NAME: admin-ui
SERVICE_LOCATION: admin-ui
# Steps represent a sequence of tasks that will be executed as part of the job
steps:
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- uses: actions/checkout@v2
- uses: actions/setup-node@v1
with:
node-version: '14'
- name: npm install
run: cd ${{ env.SERVICE_LOCATION }} && npm install --ignore-scripts
- name: npm build
run: cd ${{ env.SERVICE_LOCATION }} && npm run-script build -- --prod --base-href . --output-path=dist
- 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
- name: setup environment
run: |
# Strip git ref prefix from version
echo "GPG_TTY=$(tty)" >> $GITHUB_ENV
echo "BRANCH_NAME=$(echo ${{ github.ref }} | sed -e 's,.*/\(.*\),\1,')" >> $GITHUB_ENV
- name: run sonar analysis
run: |
cd "./${{env.SERVICE_LOCATION}}"
echo "sonar.host.url=https://sonarcloud.io/
sonar.login=${{ secrets.SONAR_TOKEN }}
sonar.projectKey=mosip_admin-ui
sonar.organization=${{ secrets.ORG_KEY }}
sonar.sourceEncoding=UTF-8
sonar.sources=src
sonar.exclusions=**/node_modules/**
sonar.tests=src
sonar.test.inclusions=**/*.spec.ts
sonar.typescript.lcov.reportPaths=coverage/lcov.info" >> sonar-project.properties
npm install sonar-scanner && npm run sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}