Skip to content

HCX API-Gateway - Build #109

HCX API-Gateway - Build

HCX API-Gateway - Build #109

name: HCX API-Gateway - Build
on:
workflow_dispatch:
inputs:
repo:
description: Custom build repository to be used
default: Swasth-Digital-Health-Foundation/hcx-platform
required: false
branch:
description: Custom build branch to be used
default: sprint-
required: true
# tags:
# - *
jobs:
build:
name: Build and Push Docker Image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
repository: ${{ github.event.inputs.repo }}
ref: ${{ github.event.inputs.branch }}
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Cache Maven dependencies
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-api-gateway
restore-keys: ${{ runner.os }}-maven-api-gateway
- name: Maven Build
run: mvn clean install -P api-gateway
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Set the Image TAG
run: echo "IMAGE_TAG=$(git rev-parse --short HEAD)" >> $GITHUB_ENV
- name: Build and push Docker image for API-Gateway
uses: docker/build-push-action@v3
with:
context: ./api-gateway
push: true
tags: |
swasth2021/api-gateway:${{ env.IMAGE_TAG }}_${{ github.run_number }}
swasth2021/api-gateway
labels: api-gateway image