Skip to content

Commit

Permalink
fix main
Browse files Browse the repository at this point in the history
  • Loading branch information
leewrigh committed Sep 8, 2024
1 parent 9b518d8 commit b81a7d3
Show file tree
Hide file tree
Showing 1,248 changed files with 15,759 additions and 17,590 deletions.
53 changes: 53 additions & 0 deletions .github/workflows/backup-prod-images.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: Backup Prod Images

on:
workflow_dispatch:
inputs:
application:
required: true
description: What application do you want to backup?
type: choice
options:
- diam-admin-frontend
- diam-approvalflow
- diam-casemanagement
- diam-config
- diam-cornet-service
- diam-disclosure
- diam-edtcore
- diam-frontend
- islinterfaces
- diam-jumapi
- diam-kafka-connectors
- diam-maintenance
- diam-notification
- diam-sso
- diam-webapi

env:
IMAGE_NAME: ${{ github.event.inputs.application }}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: Pull Prod Image
run: |
docker pull artifacts.developer.gov.bc.ca/de27-general-docker/${{env.IMAGE_NAME}}:main
- name: Build Image
run: |
docker tag artifacts.developer.gov.bc.ca/de27-general-docker/${{env.IMAGE_NAME}}:main artifacts.developer.gov.bc.ca/de27-general-docker/${{env.IMAGE_NAME}}:main-backup
- name: Docker Push to Artifactory
run: |
docker push artifacts.developer.gov.bc.ca/de27-general-docker/${{env.IMAGE_NAME}}:main-backup
7 changes: 4 additions & 3 deletions .github/workflows/build-push-approvalflow.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: diam-approvalflow

on:
push:
branches: [develop,test,main]
branches: [develop,test,main]
paths:
- "backend/ApprovalFlow/**"
- "backend/common/**"
- ".github/workflows/build-push-approvalflow.yml"
workflow_dispatch:
env:
Expand Down Expand Up @@ -81,8 +82,8 @@ jobs:


- name: Update Helm Values and Commit
id: helm
if: steps.gitops.outcome == 'success' # Only run if the previous step (publish) was successful
id: helm-dev
if: github.ref == 'refs/heads/develop' && steps.gitops.outcome == 'success' # Only run if the previous step (publish) was successful
run: |
echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment"
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/build-push-casemanagement.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@ name: diam-casemanagement

on:
push:
branches: [develop,test,main]
branches: [develop,test,main]
paths:
- "backend/edt.casemanagement/**"
- "backend/common/**"
- ".github/workflows/build-push-casemanagement.yml"
workflow_dispatch:
env:
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/build-push-diamconfig.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [develop,test,main]
paths:
- "backend/DIAMConfiguration/**"
- "backend/common/**"
- ".github/workflows/build-push-diamconfig.yml"
workflow_dispatch:
env:
Expand Down
117 changes: 117 additions & 0 deletions .github/workflows/build-push-diamcornet.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
name: diam-cornetservice

on:
push:
branches: [develop,test,main]
paths:
- "backend/DIAMCornetService/**"
- "backend/common/**"
- ".github/workflows/build-push-diamcornet.yml"
workflow_dispatch:
env:
IMAGE_NAME: diam-cornet-service
WORKING_DIRECTORY: ./backend
BRANCH_NAME: develop
VALUES_FILE: dev

jobs:
build:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v3

- name: Set environment for branch
run: |
if [[ ${{ github.ref_name }} == 'main' ]]; then
echo "BRANCH_NAME=main" >> "$GITHUB_ENV"
echo "VALUES_FILE=prod" >> "$GITHUB_ENV"
fi
if [[ ${{ github.ref_name }} == 'test' ]]; then
echo "BRANCH_NAME=test" >> "$GITHUB_ENV"
echo "VALUES_FILE=test" >> "$GITHUB_ENV"
fi
if [[ ${{ github.ref_name }} == 'develop' ]]; then
echo "BRANCH_NAME=develop" >> "$GITHUB_ENV"
echo "VALUES_FILE=dev" >> "$GITHUB_ENV"
fi
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Branch name
run: echo running on branch ${GITHUB_REF##*/}

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: Build Image
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker build -t artifacts.developer.gov.bc.ca/de27-general-docker/${{env.IMAGE_NAME}}:${GITHUB_REF##*/} -f Dockerfile.DIAMCornetService .
- name: Docker Push to Artifactory
id: publish
run: |
docker push artifacts.developer.gov.bc.ca/de27-general-docker/${{env.IMAGE_NAME}}:${GITHUB_REF##*/}
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"
- name: Checkout ArgoCD Repo
id: gitops
if: steps.publish.outcome == 'success'
uses: actions/checkout@v4
with:
repository: bcgov-c/tenant-gitops-e27db1
ref: ${{ env.BRANCH_NAME }}
token: ${{ secrets.ARGO_PAT }} # access token
path: gitops

- name: Update Helm Values and Commit
id: helm
if: steps.gitops.outcome == 'success' # Only run if the previous step (publish) was successful
run: |
echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment "
# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test
cd gitops/charts
# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
echo "Updating tag apitag: to ${{ steps.short_sha.outputs.SHORT_SHA }}"
sed -i "s/apitag: .*/apitag: ${{ env.VALUES_FILE }}-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/${{ env.VALUES_FILE }}_values.yaml
sed -i "s/apitag: .*/apitag: ${{ env.VALUES_FILE }}-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" diam-cornet/values.yaml
# Commit and push the changes
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git add .
git add ../deploy/${{ env.VALUES_FILE }}_values.yaml
# Repackage Helm Chart
cd diam-cornet
helm dependency build
git add .
git commit -m "Update ${{ env.BRANCH_NAME }} API image tag"
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed
1 change: 1 addition & 0 deletions .github/workflows/build-push-disclosure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [develop,test,main]
paths:
- "backend/edt.disclosure/**"
- "backend/common/**"
- ".github/workflows/build-push-disclosure.yml"
workflow_dispatch:
env:
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/build-push-edtcore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [develop,test,main]
paths:
- "backend/service.edt/**"
- "backend/common/**"
- ".github/workflows/build-push-edtcore.yml"
workflow_dispatch:
env:
Expand Down Expand Up @@ -89,6 +90,7 @@ jobs:
echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment "
# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test
cd gitops/charts
# Update the Helm values file with the new image tag and version
Expand All @@ -105,9 +107,10 @@ jobs:
git add .

git add ../deploy/${{ env.VALUES_FILE }}_values.yaml

# Repackage Helm Chart
cd edt-service

# Repackage Helm Chart
cd edt-service


helm dependency build

Expand All @@ -116,3 +119,4 @@ jobs:
git commit -m "Update ${{ env.BRANCH_NAME }} API image tag"
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed


2 changes: 1 addition & 1 deletion .github/workflows/build-push-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ jobs:
if: steps.gitops.outcome == 'success' # Only run if the previous step (publish) was successful
run: |
echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment"
echo "Updating helm ${{ env.BRANCH_NAME }} values to trigger ArgoCD deployment"
# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test
cd gitops/charts
Expand Down
121 changes: 121 additions & 0 deletions .github/workflows/build-push-islinterfaces.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
name: diam-islinterfaces

on:
push:
branches: [develop,test,main]
paths:
- "backend/ISLInterfaces/**"
- "backend/common/**"
- ".github/workflows/build-push-islinterfaces.yml"
workflow_dispatch:
env:
IMAGE_NAME: islinterfaces
WORKING_DIRECTORY: ./backend
BRANCH_NAME: develop
VALUES_FILE: dev

jobs:
build:
runs-on: ubuntu-latest
if: github.event_name == 'push'

steps:
- uses: actions/checkout@v3

- name: Set environment for branch
run: |
if [[ ${{ github.ref_name }} == 'main' ]]; then
echo "BRANCH_NAME=main" >> "$GITHUB_ENV"
echo "VALUES_FILE=prod" >> "$GITHUB_ENV"
fi
if [[ ${{ github.ref_name }} == 'test' ]]; then
echo "BRANCH_NAME=test" >> "$GITHUB_ENV"
echo "VALUES_FILE=test" >> "$GITHUB_ENV"
fi
if [[ ${{ github.ref_name }} == 'develop' ]]; then
echo "BRANCH_NAME=develop" >> "$GITHUB_ENV"
echo "VALUES_FILE=dev" >> "$GITHUB_ENV"
fi
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch

- name: Branch name
run: echo running on branch ${GITHUB_REF##*/}

- name: Login to Artifactory
uses: docker/login-action@v1
with:
registry: artifacts.developer.gov.bc.ca
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_PASSWORD }}

- name: Build Image
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker build -t artifacts.developer.gov.bc.ca/de27-general-docker/${{env.IMAGE_NAME}}:${GITHUB_REF##*/} -f Dockerfile.ISLInterfaces .
- name: Docker Push to Artifactory
id: publish
run: |
docker push artifacts.developer.gov.bc.ca/de27-general-docker/${{env.IMAGE_NAME}}:${GITHUB_REF##*/}
- name: Get short SHA
id: short_sha
run: |
echo "::set-output name=SHORT_SHA::$(git rev-parse --short HEAD)"
echo "Short SHA: $SHORT_SHA"
- name: Checkout ArgoCD Repo
id: gitops
if: steps.publish.outcome == 'success'
uses: actions/checkout@v4
with:
repository: bcgov-c/tenant-gitops-e27db1
ref: ${{ env.BRANCH_NAME }}
token: ${{ secrets.ARGO_PAT }} # access token
path: gitops


- name: Update Helm Values and Commit
id: helm-dev
if: github.ref == 'refs/heads/develop' && steps.gitops.outcome == 'success' # Only run if the previous step (publish) was successful
run: |
echo "Updating ${{ env.BRANCH_NAME }} helm values to trigger ArgoCD deployment"
# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test
cd gitops/charts
# Update the Helm values file with the new image tag and version
DATETIME=$(date +'%Y-%m-%d %H:%M:%S') # Get current date and time
echo "Updating tag apitag: to ${{ steps.short_sha.outputs.SHORT_SHA }}"
sed -i "s/apitag: .*/apitag: ${{ env.VALUES_FILE }}-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" ../deploy/${{ env.VALUES_FILE }}_values.yaml
sed -i "s/apitag: .*/apitag: ${{ env.VALUES_FILE }}-${{ steps.short_sha.outputs.SHORT_SHA }} # Image Updated on $DATETIME/" islinterfaces/values.yaml
# Commit and push the changes
git config --global user.email "actions@github.com"
git config --global user.name "GitHub Actions"
git add .
git add ../deploy/${{ env.VALUES_FILE }}_values.yaml
# Repackage Helm Chart
cd islinterfaces
helm dependency build
git add .
git commit -m "Update ${{ env.BRANCH_NAME }} API image tag"
git push origin ${{ env.BRANCH_NAME }} # Update the branch name as needed
1 change: 1 addition & 0 deletions .github/workflows/build-push-jumapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ on:
branches: [develop,test,main]
paths:
- "backend/jumwebapi/**"
- "backend/common/**"
- ".github/workflows/build-push-jumapi.yml"
workflow_dispatch:
env:
Expand Down
Loading

0 comments on commit b81a7d3

Please sign in to comment.