Skip to content

adjust build

adjust build #37

# GitHub Actions pipeline for DFA UI Public Portal component
name: cd-dfa-portal-public-ui
on:
push:
branches:
- support-develop
- develop
paths:
- "dfa-public/src/UI/**"
- ".github/workflows/cd-dfa-portal-public-ui.yml"
workflow_dispatch:
env:
IMAGE_NAME: dfa-portal-ui-public
WORKING_DIRECTORY: ./dfa-public/src/UI
IMAGE_TAG: dev
jobs:
build:
runs-on: ubuntu-latest
if: github.event_name == 'push'
steps:
- uses: actions/checkout@v3
- name: Log into registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.DOCKER_PROJECT_REGISTRY }}
username: ${{ secrets.DOCKER_PROJECT_USERNAME }}
password: ${{ secrets.DOCKER_PROJECT_PASSWORD_BUILDER }}
# Get SHORT_SHA to tag images
- 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: Build Image
working-directory: ${{env.WORKING_DIRECTORY}}
run: |
docker build -t ${{env.IMAGE_NAME}} .
- name: Tag Image
run: |
docker tag ${{env.IMAGE_NAME}} ${{ secrets.DOCKER_PROJECT_REGISTRY }}/${{env.IMAGE_NAME}}:${{ env.IMAGE_TAG }}
- name: Docker Push
run: |
docker push ${{ secrets.DOCKER_PROJECT_REGISTRY }}/${{env.IMAGE_NAME}}:${{ env.IMAGE_TAG }}
- name: Checkout ArgoCD Repo
id: gitops
uses: actions/checkout@v4
with:
repository: bcgov-c/tenant-gitops-c2ee1a
ref: develop
token: ${{ secrets.GITOPS_KEY }} # `GH_PAT` is a secret that contains your PAT
path: gitops
- name: Update Helm values in gitops
id: helm
if: steps.gitops.outcome == 'success' # Only run if the previous step (publish) was successful
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/uipubtag: .*/uipubtag: dev # Image Updated on $DATETIME/" ../deploy/dev_public_values.yaml
sed -i "s/uipubversion: .*/uipubversion: v-${{ steps.short_sha.outputs.SHORT_SHA }} # Version Updated on $DATETIME/" ../deploy/dev_public_values.yaml
sed -i "s/uipubtag: .*/uipubtag: dev # Image Updated on $DATETIME/" dfa-portal-ui-public/values.yaml
sed -i "s/uipubversion: .*/uipubversion: v-${{ steps.short_sha.outputs.SHORT_SHA }} # Version Updated on $DATETIME/" dfa-portal-ui-public/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/dev_public_values.yaml
# Repackage Helm Chart
cd dfa-gitops-public
helm dependency build
cd charts
git add .
git commit -m "Update Dev UI image tag"
git push origin develop # Update the branch name as needed