Skip to content

Commit

Permalink
Merge pull request #1514 from gofr-dev/docs-deploy1
Browse files Browse the repository at this point in the history
Improve the workflow to deploy website
  • Loading branch information
aryanmehrotra authored Feb 24, 2025
1 parent 129dbb5 commit 71f8832
Showing 1 changed file with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ on:
branches:
- main
- development

env:
APP_NAME: gofr-website
WEBSITE_REGISTRY: ghcr.io
Expand All @@ -15,42 +14,13 @@ env:
CLUSTER_NAME: raramuri-tech
CLUSTER_PROJECT: raramuri-tech
NAMESPACE: gofr-dev
NAMESPACE_STAGE: gofr-dev-stg
jobs:
build:
runs-on: ubuntu-latest
name: 🔧Build
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to the GitHub Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.WEBSITE_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Download UI Image
run: |
docker pull ${{ env.WEBSITE_REGISTRY }}/gofr-dev/website:latest
- name: Build Image
uses: docker/build-push-action@v6
with:
push: false
context: ./
file: ./docs/Dockerfile

dockerize:
if: ${{ startsWith(github.ref, 'refs/tags/v')}}
runs-on: ubuntu-latest
outputs:
image: ${{ steps.output-image.outputs.image }}
name: 🐳 Dockerize
needs: build
steps:
- name: Checkout Code
uses: actions/checkout@v4
Expand Down Expand Up @@ -87,9 +57,37 @@ jobs:
- id: output-image
run: echo "image=`echo us-central1-docker.pkg.dev/${{ env.GAR_PROJECT }}/${{ env.GAR_REGISTRY }}/${{ env.APP_NAME }}:${{ github.sha }}`" >> "$GITHUB_OUTPUT"

deployment_stage:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/development' }}
name: 🚀 Deploy-Stage
needs: dockerize
container:
image: ghcr.io/zopsmart/gha-images:deployments-0.1.3
options: --rm
env:
image: ${{needs.dockerize.outputs.image}}

steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Authorize to GCP service account
uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.deploy_key }}

- name: Set GCloud Project and Fetch Cluster Credentials
run: gcloud container clusters get-credentials ${{ env.CLUSTER_NAME }} --region=us-central1 --project=${{ env.CLUSTER_PROJECT }}

- name: Update Deployment Image
run: kubectl set image deployment/${{ env.APP_NAME }} ${{ env.APP_NAME }}=${{ env.image }} --namespace ${{ env.NAMESPACE_STAGE }}


deployment:
if: ${{ startsWith(github.ref, 'refs/tags/v')}}
runs-on: ubuntu-latest
name: 🚀 Deploy
name: 🚀 Deploy-Prod
needs: dockerize
container:
image: ghcr.io/zopsmart/gha-images:deployments-0.1.3
Expand Down

0 comments on commit 71f8832

Please sign in to comment.