From bb6b598aea1e7c9aa29c5919ed64a3608e03f030 Mon Sep 17 00:00:00 2001 From: soringumeni1 Date: Mon, 30 Oct 2023 13:18:10 +0000 Subject: [PATCH 1/2] GAT-2878: Add CI/CD pipeline --- .github/workflows/dev_deployment.yaml | 101 ++++++++++++++++++++++++++ chart/fma/Chart.yaml | 24 ++++++ 2 files changed, 125 insertions(+) create mode 100644 .github/workflows/dev_deployment.yaml create mode 100644 chart/fma/Chart.yaml diff --git a/.github/workflows/dev_deployment.yaml b/.github/workflows/dev_deployment.yaml new file mode 100644 index 0000000..fc246b2 --- /dev/null +++ b/.github/workflows/dev_deployment.yaml @@ -0,0 +1,101 @@ +name: Build and deploy to DEV +run-name: ${{ github.actor }} triggered deploy to DEV pipeline + +on: + push: + branches: + - 'dev' + - 'GAT-2878' + +env: + PROJECT_ID: '${{ secrets.PROJECT_ID }}' + GAR_LOCATION: '${{ secrets.GAR_LOCATION }}' + +jobs: + build: + permissions: + contents: write + id-token: write + + runs-on: ubuntu-latest + environment: dev + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: GAT-2878 + + - name: Read VERSION file + id: getversion + run: | + sed -n 's/^appVersion:\(.*\)/\1/p' < chart/fma/Chart.yaml > version + echo "version=$(sed '/.*\"\(.*\)\".*/ s//\1/g' version)" >> $GITHUB_OUTPUT + + - name: Google Auth + id: auth + uses: 'google-github-actions/auth@v0' + with: + token_format: 'access_token' + workload_identity_provider: '${{ secrets.WIF_PROVIDER }}' + service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}' + + - name: Login to GAR + id: garlogin + uses: docker/login-action@v2 + with: + registry: ${{ env.GAR_LOCATION }}-docker.pkg.dev/${{ env.PROJECT_ID }}/${{ env.PROJECT_ID }} + username: oauth2accesstoken + password: ${{ steps.auth.outputs.access_token }} + + - name: Build and Push Container + id: build + shell: bash + env: + GAR_LOCATION: ${{ secrets.GAR_LOCATION }} + PROJECT_ID: ${{ secrets.PROJECT_ID }} + GAR_NAME: ${{ secrets.GAR_NAME }} + + run: |- + docker build -t '${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:${{ github.sha }} -t '${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:latest ./ + docker push --all-tags '${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }} + + deploy: + needs: build + permissions: + contents: write + id-token: write + + runs-on: ubuntu-latest + environment: dev + steps: + - name: Checkout + uses: actions/checkout@v3 + with: + ref: GAT-2878 + + - name: Google Auth + id: auth + uses: 'google-github-actions/auth@v0' + with: + token_format: 'access_token' + workload_identity_provider: '${{ secrets.WIF_PROVIDER }}' + service_account: '${{ secrets.WIF_SERVICE_ACCOUNT }}' + + - name: Read VERSION file + id: getversion + run: | + sed -n 's/^appVersion:\(.*\)/\1/p' < chart/fma/Chart.yaml > version + echo "version=$(sed '/.*\"\(.*\)\".*/ s//\1/g' version)" >> $GITHUB_OUTPUT + + - name: Deploy to Cloud Run + uses: actions-hub/gcloud@master + id: deploy + env: + PROJECT_ID: ${{ secrets.PROJECT_ID }} + GAR_LOCATION: ${{ secrets.GAR_LOCATION }} + GAR_NAME: ${{ secrets.GAR_NAME }} + SERVICE_NAME: '${{ secrets.SERVICE_NAME }}' + SERVICE_REGION: '${{ secrets.SERVICE_REGION }}' + + with: + args: run services update '${{ env.SERVICE_NAME }}' --image='${{ env.GAR_LOCATION }}'-docker.pkg.dev/'${{ env.PROJECT_ID }}'/'${{ env.GAR_NAME }}'/${{ steps.getversion.outputs.version }}:${{ github.sha }} --region='${{ env.SERVICE_REGION }}' --project='${{ env.PROJECT_ID }}' \ No newline at end of file diff --git a/chart/fma/Chart.yaml b/chart/fma/Chart.yaml new file mode 100644 index 0000000..37d0dbe --- /dev/null +++ b/chart/fma/Chart.yaml @@ -0,0 +1,24 @@ +apiVersion: v2 +name: fma +description: A Helm chart for Kubernetes + +# A chart can be either an 'application' or a 'library' chart. +# +# Application charts are a collection of templates that can be packaged into versioned archives +# to be deployed. +# +# Library charts provide useful utilities or functions for the chart developer. They're included as +# a dependency of application charts to inject those utilities and functions into the rendering +# pipeline. Library charts do not define any templates and therefore cannot be deployed. +type: application + +# This is the chart version. This version number should be incremented each time you make changes +# to the chart and its templates, including the app version. +# Versions are expected to follow Semantic Versioning (https://semver.org/) +version: 1.0.0 + +# This is the version number of the application being deployed. This version number should be +# incremented each time you make changes to the application. Versions are not expected to +# follow Semantic Versioning. They should reflect the version the application is using. +# It is recommended to use it with quotes. +appVersion: "1.0.0" From 3dbb1bdc9632e35cac3b73f62a98f28d4fe10e98 Mon Sep 17 00:00:00 2001 From: soringumeni1 Date: Mon, 30 Oct 2023 13:31:01 +0000 Subject: [PATCH 2/2] GAT-2878: Remove test data --- .github/workflows/dev_deployment.yaml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/.github/workflows/dev_deployment.yaml b/.github/workflows/dev_deployment.yaml index fc246b2..dbe000a 100644 --- a/.github/workflows/dev_deployment.yaml +++ b/.github/workflows/dev_deployment.yaml @@ -4,8 +4,7 @@ run-name: ${{ github.actor }} triggered deploy to DEV pipeline on: push: branches: - - 'dev' - - 'GAT-2878' + - 'main' env: PROJECT_ID: '${{ secrets.PROJECT_ID }}' @@ -23,7 +22,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - ref: GAT-2878 + ref: main - name: Read VERSION file id: getversion @@ -71,7 +70,7 @@ jobs: - name: Checkout uses: actions/checkout@v3 with: - ref: GAT-2878 + ref: main - name: Google Auth id: auth