Promote to Test #4
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
# Deploy an artifact onto Test | |
name: Promote to Test | |
on: | |
workflow_dispatch: | |
inputs: | |
application: | |
required: true | |
description: What application you want to promote? | |
type: choice | |
options: | |
- ai-reviewer-api | |
- ai-reviewer-admin | |
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.EFILING_ARTIFACTORY_USERNAME }} | |
password: ${{ secrets.EFILING_ARTIFACTORY_PASSWORD }} | |
- name: Docker Pull Dev Image from Artifactory | |
working-directory: ${{env.WORKING_DIRECTORY}} | |
run: | | |
docker pull artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:dev | |
docker tag artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:dev artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:test | |
- name: Docker Push Test Image To Artifactory | |
working-directory: ${{env.WORKING_DIRECTORY}} | |
run: | | |
docker push artifacts.developer.gov.bc.ca/efc7-${{ github.event.inputs.application }}/${{ github.event.inputs.application }}:test | |
# Get SHORT_SHA for the version | |
- 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 | |
uses: actions/checkout@v4 | |
with: | |
repository: bcgov-c/tenant-gitops-fc726a | |
ref: test | |
token: ${{ secrets.ARGO_PAT }} # `GH_PAT` is a secret that contains your PAT | |
path: gitops | |
- name: Update ADMIN Helm Values and Commit | |
id: helm-admin | |
if: ${{ github.event.inputs.application == 'ai-reviewer-admin' }} | |
run: | | |
# Clone the GitOps deployment configuration repository | |
# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test and | |
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 | |
sed -i "s/aiadmintag: .*/aiadmintag: test # Image Updated on $DATETIME/" ../deploy/test_values.yaml | |
sed -i "s/aiAdminVersion: .*/aiAdminVersion: ${{ steps.short_sha.outputs.SHORT_SHA }} # Version Updated on $DATETIME/" ../deploy/test_values.yaml | |
# Commit and push the changes | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git add . | |
git add ../deploy/test_values.yaml | |
# Repackage Helm Chart | |
cd efiling-gitops | |
helm dependency build | |
cd charts | |
git add . | |
git commit -m "Update Test AI Reviewer Admin image tag" | |
git push origin test # Update the branch name as needed | |
- name: Update API Helm Values and Commit | |
id: helm-api | |
if: ${{ github.event.inputs.application == 'ai-reviewer-api' }} | |
run: | | |
# Clone the GitOps deployment configuration repository | |
# Navigate to the directory containing your Helm values file for the environment develop -> DEV, test -> test and | |
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 | |
sed -i "s/aiapitag: .*/aiapitag: test # Image Updated on $DATETIME/" ../deploy/test_values.yaml | |
sed -i "s/aiApiVersion: .*/aiApiVersion: ${{ steps.short_sha.outputs.SHORT_SHA }} # Version Updated on $DATETIME/" ../deploy/test_values.yaml | |
# Commit and push the changes | |
git config --global user.email "[email protected]" | |
git config --global user.name "GitHub Actions" | |
git add . | |
git add ../deploy/test_values.yaml | |
# Repackage Helm Chart | |
cd efiling-gitops | |
helm dependency build | |
cd charts | |
git add . | |
git commit -m "Update Test AI Reviewer API image tag" | |
git push origin test # Update the branch name as needed |