CR deployment #11
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
# This is a basic workflow that is manually triggered | |
# try to use as much shell scripting a possible | |
# actions appear from default branch - https://github.community/t/workflow-files-only-picked-up-from-master/16129/2 | |
name: CR deployment | |
on: | |
workflow_dispatch: | |
# Inputs the workflow accepts. | |
inputs: | |
tag_repo: | |
description: 'repo branch or tag' | |
default: 'main' | |
required: true | |
tag_cr: | |
description: 'container image tag' | |
default: 'latest' | |
required: true | |
env: | |
REPO_NAME: ${{ github.event.repository.name }} | |
CR_PASSWORD: ${{ secrets.CR_PASSWORD }} | |
CR_USERNAME: ${{ secrets.CR_USERNAME }} | |
CR_HOST: ${{ vars.CR_HOST }} | |
CR_NS: ${{ vars.CR_NS }} | |
DOCKERFILE_TARGET: production # follow value in docker file | |
jobs: | |
deploy_to_cr: | |
runs-on: ubuntu-latest | |
name: Deploying CR | |
steps: | |
# - name: Selected Branch/tag | |
# run: echo ${{ github.event.inputs.tag_repo }} | |
# - name: Add checkout plugin | |
# uses: actions/checkout@v3 | |
# with: | |
# ref: ${{ github.event.inputs.tag_repo }} | |
- name: Build and push image to CR | |
env: | |
IMAGE_TARGET: production | |
IMAGE_TAG: ${{ github.sha }} | |
run: | | |
# cat password.txt | | |
# docker login --username=${CR_USERNAME} --password=${CR_PASSWORD} ${CR_HOST} | |
echo "starting docker builds 1" | |
echo `ls` | |
echo $CR_PASSWORD | docker login --username $CR_USERNAME --password-stdin $CR_HOST | |
docker build -t $CR_HOST/$CR_NS/$REPO_NAME:${{ github.event.inputs.tag_repo }} --target $DOCKERFILE_TARGET --build-arg ARG_NODE_ENV=$DOCKERFILE_TARGET --build-arg ARG_API_PORT=3000 . || exit 1001 | |
docker push $CR_HOST/$CR_NS/$REPO_NAME:${{ github.event.inputs.tag_repo }} | |
docker logout |