Skip to content

Commit

Permalink
Merge pull request #26 from bcgov/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
DarylTodosichuk authored Aug 29, 2024
2 parents 9cdf586 + f748643 commit b794916
Show file tree
Hide file tree
Showing 4 changed files with 118 additions and 46 deletions.
73 changes: 50 additions & 23 deletions .github/workflows/docker-build-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,42 +15,69 @@ on:
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'README.md'
- 'SECURITY..md'

- 'SECURITY.md'
env:
CLUSTER: https://api.silver.devops.gov.bc.ca:6443
AUTH_TOKEN: ${{ secrets.OPENSHIFT_TOKEN_DEV }}
TARGET_PROJECT: ${{ vars.PROJECT_NAMESPACE }}
TARGET_ENV: ${{ vars.NAME }}
ART_REPO_USER: ${{ secrets.ARTIFACTORY_USER_DEV }}
ART_REPO_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN_DEV }}
TARGET_ENV: dev
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 }}

# 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
build:

runs-on: ubuntu-latest
environment: dev
steps:
- uses: actions/checkout@v4
- name: Build application Docker images
- 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
- name: Connect to JFrog Artifactory
working-directory: ./applications/aspnetapp
- name: Connect to JFrog Artifactory non-interactive login using --password-stdin
run: |
docker login --username $ART_REPO_USER --password $ART_REPO_TOKEN artifacts.developer.gov.bc.ca
echo "$JFROG_PASSWORD" | docker login -u "$JFROG_USERNAME" --password-stdin $JFROG_SERVICE
- name: Push application images to Artifactory container registry
run: |
docker tag dotnetapp image-registry.apps.silver.devops.gov.bc.ca/$TARGET_PROJECT-$TARGET_ENV/dotnetapp:github-latest
# docker push image-registry.apps.silver.devops.gov.bc.ca/$TARGET_PROJECT-$TARGET_ENV/dotnetapp:github-latest
- name: Connect to OpenShift API
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
- name: Disconnect docker from JFrog Artifactory
run: |
oc login --token=$AUTH_TOKEN --server=$CLUSTER
oc project $TARGET_PROJECT-$TARGET_ENV
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 image-registry.apps.silver.devops.gov.bc.ca/$TARGET_PROJECT-$TARGET_ENV/dotnetapp:github-latest
# docker push image-registry.apps.silver.devops.gov.bc.ca/$TARGET_PROJECT-$TARGET_ENV/dotnetapp:github-latest
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
- name: Disconnect docker from OpenShift container registry
run: |
docker logout
73 changes: 55 additions & 18 deletions .github/workflows/docker-build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,33 +15,70 @@ on:
- 'CONTRIBUTING.md'
- 'LICENSE'
- 'README.md'
- 'SECURITY..md'
- 'SECURITY.md'

env:
CLUSTER: https://api.silver.devops.gov.bc.ca:6443
AUTH_TOKEN: ${{ secrets.OPENSHIFT_TOKEN_TEST }}
TARGET_PROJECT: ${{ vars.PROJECT_NAMESPACE }}
TARGET_ENV: test

jobs:
TARGET_ENV: test
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 }}

# 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: test
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
build:

runs-on: ubuntu-latest

environment: test
steps:
- uses: actions/checkout@v4
- name: Build application Docker images
- 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
- name: Connect to OpenShift API
working-directory: ./applications/aspnetapp
- 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
- 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=$AUTH_TOKEN --server=$CLUSTER
oc project $TARGET_PROJECT-$TARGET_ENV
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 webapp image-registry.apps.silver.devops.gov.bc.ca/$TARGET_PROJECT-$TARGET_ENV/webapp:github-latest
docker push image-registry.apps.silver.devops.gov.bc.ca/$TARGET_PROJECT-$TARGET_ENV/webapp:github-latest
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
- name: Disconnect docker from OpenShift container registry
run: |
docker logout
9 changes: 4 additions & 5 deletions .github/workflows/manual-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,20 +30,19 @@ env:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
# This workflow contains a single job called "greet"
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: ${{ inputs.name }}
steps:
# Runs a single command using the runners shell
# Runs commands using the runners shell
- name: Get variables
run: |
echo "target=${{ inputs.name }} "
echo "target=$TARGET_ENV "
echo "base=$GITHUB_REF_NAME"
echo "Environment: ${{ inputs.name }} OC_TARGET_PROJECT=$OC_TARGET_PROJECT"
echo "Environment: ${{ inputs.name }} JFROG_REPO_PATH=$JFROG_REPO_PATH"
echo "Environment: $TARGET_ENV OC_TARGET_PROJECT=$OC_TARGET_PROJECT"
echo "Environment: $TARGET_ENV JFROG_REPO_PATH=$JFROG_REPO_PATH"
echo "..."
env | sort
build:
Expand Down
9 changes: 9 additions & 0 deletions applications/program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
using System;
using System.Diagnostics.CodeAnalysis;
using System.IO;
using System.Net;
using System.Runtime.InteropServices;
using static System.Console;

Console.WriteLine("Run...");
while (true);

0 comments on commit b794916

Please sign in to comment.