Merge pull request #467 from sam-warren/embcdfa-1099 #30
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
#CD pipeline for dfa ui public | |
name: cd-dfae-project-public-ui | |
on: | |
push: | |
branches: | |
- develop | |
paths: | |
- "dfa-public/src/UI/**" | |
- ".github/workflows/cd-dfae-project-public-ui.yml" | |
workflow_dispatch: | |
env: | |
IMAGE_NAME: dfa-portal-ui-public | |
WORKING_DIRECTORY: ./dfa-public/src/UI | |
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 }} | |
- 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}}:dev | |
- name: Docker Push | |
run: | | |
docker push ${{ secrets.DOCKER_PROJECT_REGISTRY }}/${{env.IMAGE_NAME}}:dev | |
- 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/uitag: .*/uitag: dev # Image Updated on $DATETIME/" ../deploy/dev_public_values.yaml | |
sed -i "s/uitag: .*/uitag: dev # Image Updated on $DATETIME/" dfa-portal-ui-public/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/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 |