HCX-APIs - Build #187
This file contains hidden or 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: HCX-APIs - 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: main | |
required: true | |
jobs: | |
build: | |
name: Build and Push Docker Image | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
repository: ${{ github.event.inputs.repo }} | |
ref: ${{ github.event.inputs.branch }} | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Cache Maven dependencies | |
uses: actions/cache@v3 | |
with: | |
path: ~/.m2/repository | |
key: ${{ runner.os }}-maven-hcx-apis-${{ hashFiles('**/pom.xml') }} | |
restore-keys: | | |
${{ runner.os }}-maven-hcx-apis | |
- name: Maven Build | |
run: mvn clean install -P hcx-apis -DskipTests | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Log in to Docker Hub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: Set Image Tag | |
run: echo "IMAGE_TAG=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Build and Push Docker Image | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./hcx-apis | |
push: true | |
tags: | | |
swasth2021/hcx-api:${{ env.IMAGE_TAG }}_${{ github.run_number }} | |
swasth2021/hcx-api:latest | |
labels: | | |
maintainer=swasth2021 | |
app=hcx-api |