HCX Mock Service - Build #46
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: HCX Mock Service - Build | |
on: | |
workflow_dispatch: | |
inputs: | |
repo: | |
description: Custom build repository to be used | |
required: false | |
branch: | |
description: Custom build branch to be used | |
required: false | |
# 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-${{ hashFiles('**/pom.xml') }} | |
restore-keys: ${{ runner.os }}-maven- | |
- name: Maven Build | |
run: | | |
mvn clean install -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 the Image TAG | |
run: echo "IMAGE_TAG=$(git rev-parse --short HEAD)" >> $GITHUB_ENV | |
- name: Build and push Docker image for HCX Mock Service | |
uses: docker/build-push-action@v3 | |
with: | |
context: ./ | |
push: true | |
tags: swasth2021/hcx-mock-service:${{ env.IMAGE_TAG }}_${{ github.run_number }} | |
labels: hcx-mock-service image | |
- name: Configure AWS CLI | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: ap-south-1 | |
- name: Build and push Docker image for HCX Mock Service to S3 bucket | |
run: | | |
echo ${{ env.IMAGE_TAG }}_${{ github.run_number }} >> /tmp/tag.txt | |
aws s3 cp /tmp/tag.txt s3://build-tags/tag.txt |