test 7.4 #99
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: Dev - Build & Push docker images | |
on: | |
push: | |
branches: [ "dev" ] | |
paths-ignore: | |
- '.github/**' | |
- '.gitignore' | |
- 'database/**' | |
- 'documentation/**' | |
- 'openshift/**' | |
- 'tests/**' | |
- 'CODE_OF_CONDUCT.md' | |
- 'COMPLIANCE.yaml' | |
- 'CONTRIBUTING.md' | |
- 'LICENSE' | |
- 'README.md' | |
- 'SECURITY.md' | |
env: | |
TARGET_ENV: dev | |
GH_TOKEN: ${{secrets.GH_API_TOKEN}} | |
OC_CLUSTER: ${{ vars.OPENSHIFT_CLUSTER }} | |
OC_REGISTRY: ${{ vars.OPENSHIFT_REGISTRY }} | |
OC_AUTH_TOKEN: ${{ secrets.OPENSHIFT_TOKEN }} | |
OC_TARGET_PROJECT: ${{ vars.OPENSHIFT_NAMESPACE }} | |
JFROG_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }} | |
JFROG_PASSWORD: ${{ secrets.ARTIFACTORY_PASSWORD }} | |
JFROG_REPO_PATH: ${{ vars.ARTIFACTORY_REPO }} | |
JFROG_SERVICE: ${{ vars.ARTIFACTORY_SERVICE }} | |
UGM_BUILD_VERSION: ${{vars.UGM_BUILD_VERSION}} | |
UGM_BUILD_REVISION: ${{vars.UGM_BUILD_REVISION}} | |
UGM_RELEASE_PREFIX: API_v | |
UGM_RELEASE_MESSAGE: "Development deployment" | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
Setup: | |
# The type of runner that the job will run on | |
runs-on: ubuntu-latest | |
# Steps represent a sequence of tasks that will be executed as part of the job | |
environment: dev | |
steps: | |
# Runs commands using the runners shell | |
- name: Get variables | |
run: | | |
echo "target=$TARGET_ENV" | |
echo "base=$GITHUB_REF_NAME" | |
echo "Environment: $TARGET_ENV OC_TARGET_PROJECT=$OC_TARGET_PROJECT" | |
echo "Environment: $TARGET_ENV JFROG_REPO_PATH=$JFROG_REPO_PATH" | |
echo "..." | |
env | sort | |
Branch: | |
needs: [Setup] | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: Get short commitId | |
id: get-commit | |
run: | | |
echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Get current date | |
id: date-selector | |
run: echo "date=$(date +'%B %e, %Y')" >> $GITHUB_OUTPUT | |
- name: List merged branch | |
id: get-branch | |
run: | | |
MERGED_BRANCH=$(git log --merges --pretty=format:"%s" -1 | grep -oE 'from bcgov/[^ ]+' | sed 's/from bcgov\///') | |
if [ -z "$MERGED_BRANCH" ]; then | |
echo "direct push not a PR from bcgov/branch" | |
else | |
echo "Merged branch: $MERGED_BRANCH" | |
fi | |
echo "MERGED_BRANCH=$MERGED_BRANCH" >> $GITHUB_OUTPUT | |
- name: Set repository version variables | |
id: setversion | |
run: | | |
gh variable list --env ${{env.TARGET_ENV}} | |
gh variable set UGM_BUILD_REVISION --env ${{env.TARGET_ENV}} --body "${{steps.get-commit.outputs.sha_short}}" | |
gh variable list --env ${{env.TARGET_ENV}} | |
echo "buildArgs --env ${{env.TARGET_ENV}} UNITY_BUILD_VERSION: ${{env.UGM_BUILD_VERSION}}, UNITY_BUILD_REVISION: ${{env.UGM_BUILD_REVISION}}, Merged Branch: ${{steps.get-branch.outputs.MERGED_BRANCH}}" | |
Build: | |
needs: [Setup,Branch] | |
runs-on: ubuntu-latest | |
environment: dev | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Build dotnetapp docker images | |
run: docker compose build | |
working-directory: ./applications/dotnetapp | |
- name: Build aspnetapp docker images | |
run: docker compose build | |
working-directory: ./applications/aspnetapp | |
- name: Get BuildId | |
id: commit | |
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT | |
- name: Set buildArgs | |
run: | | |
echo "buildArgs UNITY_BUILD_VERSION: ${{env.UGM_BUILD_VERSION}}, UNITY_BUILD_REVISION: ${{env.UGM_BUILD_REVISION}}" | |
- name: Build Docker images | |
run: | | |
rm -f ./docker-compose.override.yml | |
docker compose build --build-arg UNITY_BUILD_VERSION=${{env.UGM_BUILD_VERSION}} --build-arg UNITY_BUILD_REVISION=${{env.UGM_BUILD_REVISION}} | |
working-directory: ./applications/Unity.GrantManager | |
- name: Connect to JFrog Artifactory non-interactive login using --password-stdin | |
run: | | |
echo "$JFROG_PASSWORD" | docker login -u "$JFROG_USERNAME" --password-stdin $JFROG_SERVICE | |
- name: Push application images to Artifactory container registry | |
run: | | |
docker tag dotnetapp $JFROG_SERVICE/$JFROG_REPO_PATH/dotnetapp | |
docker push $JFROG_SERVICE/$JFROG_REPO_PATH/dotnetapp | |
docker tag aspnetapp $JFROG_SERVICE/$JFROG_REPO_PATH/aspnetapp | |
docker push $JFROG_SERVICE/$JFROG_REPO_PATH/aspnetapp | |
docker tag unity-grantmanager-dbmigrator $JFROG_SERVICE/$JFROG_REPO_PATH/unity-grantmanager-dbmigrator | |
docker push $JFROG_SERVICE/$JFROG_REPO_PATH/unity-grantmanager-dbmigrator | |
docker tag unity-grantmanager-web $JFROG_SERVICE/$JFROG_REPO_PATH/unity-grantmanager-web | |
docker push $JFROG_SERVICE/$JFROG_REPO_PATH/unity-grantmanager-web | |
- name: Disconnect docker from JFrog Artifactory | |
run: | | |
docker logout | |
- name: Connect to OpenShift API non-interactive login using current session token | |
run: | | |
oc login --token=$OC_AUTH_TOKEN --server=$OC_CLUSTER | |
oc registry login | |
docker login -u unused -p $(oc whoami -t) $OC_REGISTRY | |
- name: Push application images to OpenShift container registry | |
run: | | |
docker tag dotnetapp $OC_REGISTRY/$OC_TARGET_PROJECT/dotnetapp | |
docker push $OC_REGISTRY/$OC_TARGET_PROJECT/dotnetapp | |
docker tag aspnetapp $OC_REGISTRY/$OC_TARGET_PROJECT/aspnetapp | |
docker push $OC_REGISTRY/$OC_TARGET_PROJECT/aspnetapp | |
docker tag unity-grantmanager-dbmigrator $OC_REGISTRY/$OC_TARGET_PROJECT/unity-grantmanager-dbmigrator | |
docker push $OC_REGISTRY/$OC_TARGET_PROJECT/unity-grantmanager-dbmigrator | |
docker tag unity-grantmanager-web $OC_REGISTRY/$OC_TARGET_PROJECT/unity-grantmanager-web | |
docker push $OC_REGISTRY/$OC_TARGET_PROJECT/unity-grantmanager-web | |
- name: Disconnect docker from OpenShift container registry | |
run: | | |
docker logout |