Create ui-workflow.yml

This commit is contained in:
Alexey Grigorkin
2022-04-11 14:51:14 +03:00
committed by GitHub
parent fe70b0f91e
commit d6dafd93ec

65
.github/workflows/ui-workflow.yml vendored Normal file
View File

@@ -0,0 +1,65 @@
name: Reusable workflow. Used to build and push UI
on:
workflow_call:
inputs:
ECR_REPOSITORY:
description: "Docker repository address"
required: true
type: string
IS_ECR_PUSH_ENABLED:
description: "Disable pushing to ECR. Default is true."
required: true
type: boolean
secrets:
GH_TOKEN_CAN_READ_PACKAGES:
required: true
SECRET_ECR_REGISTRY:
required: true
SECRET_ECR_USERNAME:
required: true
SECRET_ECR_PASSWORD:
required: true
SECRET_IMAGE_TAG:
required: true
jobs:
ui-build-and-push-to-ecr:
runs-on: custom
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: '14'
registry-url: 'https://npm.pkg.github.com'
- run: (rm .npmrc || true) && npm install
env:
NODE_AUTH_TOKEN: ${{ secrets.GH_TOKEN_CAN_READ_PACKAGES }}
- run: npm run build
- name: Login to ECR
if: ${{ inputs.IS_ECR_PUSH_ENABLED }}
id: login-ecr
uses: docker/login-action@v1
with:
registry: ${{ secrets.SECRET_ECR_REGISTRY }}
username: ${{ secrets.SECRET_ECR_USERNAME }}
password: ${{ secrets.SECRET_ECR_PASSWORD }}
- name: Build, tag, and push image to ECR
if: ${{ inputs.IS_ECR_PUSH_ENABLED }}
env:
ECR_REGISTRY: ${{ secrets.SECRET_ECR_REGISTRY }}
ECR_REPOSITORY: ${{ inputs.ECR_REPOSITORY }}
IMAGE_TAG: ${{ secrets.SECRET_IMAGE_TAG }}
BOOT_JAR_NAME: ${{ inputs.BOOT_JAR_NAME }}
run: |
docker build --build-arg=IMAGE_TAG=$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG
docker build --build-arg=IMAGE_TAG=$IMAGE_TAG -t $ECR_REGISTRY/$ECR_REPOSITORY:latest .
docker push $ECR_REGISTRY/$ECR_REPOSITORY:latest
- name: Logout on Arbina ECR
run: docker logout ${{ secrets.SECRET_ECR_REGISTRY }}