From 0e9432b5ff73c8c8c09297680db7770186949bd8 Mon Sep 17 00:00:00 2001 From: Sabiha Khan Date: Wed, 8 Oct 2025 15:38:05 +0530 Subject: [PATCH] ci(workflows): add release and deployment automation --- .github/workflows/docker-image.yml | 9 ++-- .github/workflows/release-automation.yml | 22 +++++++++ .github/workflows/release-deployment.yml | 62 ++++++++++++++++++++++++ .gitignore | 3 +- .release-please-manifest.json | 3 ++ release-please-config.json | 23 +++++++++ ui/package.json | 2 +- 7 files changed, 117 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/release-automation.yml create mode 100644 .github/workflows/release-deployment.yml create mode 100644 .release-please-manifest.json create mode 100644 release-please-config.json diff --git a/.github/workflows/docker-image.yml b/.github/workflows/docker-image.yml index ac00cba..d2b9962 100644 --- a/.github/workflows/docker-image.yml +++ b/.github/workflows/docker-image.yml @@ -1,11 +1,10 @@ name: Build and Push Docker Images on: - push: - branches: - - main + release: + types: [published] -# Ensure only one workflow run per branch at a time; cancel any in-progress runs on new push +# Ensure only one workflow run per branch at a time; cancel any in-progress runs on new push concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true @@ -19,7 +18,7 @@ jobs: strategy: matrix: service: - - "dograh-api|api/Dockerfile|./api" + - "dograh-api|api/Dockerfile|." - "dograh-ui|ui/Dockerfile|./ui" steps: diff --git a/.github/workflows/release-automation.yml b/.github/workflows/release-automation.yml new file mode 100644 index 0000000..5b17410 --- /dev/null +++ b/.github/workflows/release-automation.yml @@ -0,0 +1,22 @@ +name: Release Please + +on: + push: + branches: + - main + +permissions: + contents: write + pull-requests: write + +jobs: + release-please: + runs-on: ubuntu-latest + steps: + - uses: googleapis/release-please-action@v4 + with: + # Config files location + config-file: release-please-config.json + manifest-file: .release-please-manifest.json + # Use PAT to trigger deployment workflow + token: ${{ secrets.RELEASE_PLEASE_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-deployment.yml b/.github/workflows/release-deployment.yml new file mode 100644 index 0000000..034d695 --- /dev/null +++ b/.github/workflows/release-deployment.yml @@ -0,0 +1,62 @@ +name: Deploy to Vercel Production + +on: + release: + types: [published] + +jobs: + deploy: + runs-on: ubuntu-latest + environment: production + steps: + - name: Checkout code + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Install Vercel CLI + run: npm install --global vercel@latest + + - name: Pull Vercel Environment Information + run: vercel pull --yes --environment=production --token=$VERCEL_TOKEN + env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + + - name: Build Project Artifacts + run: vercel build --prod --token=$VERCEL_TOKEN + env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + + - name: Deploy to Vercel Production + run: | + DEPLOYMENT_URL=$(vercel deploy --prebuilt --prod --token=$VERCEL_TOKEN) + echo "Deployed to: $DEPLOYMENT_URL" + echo "deployment_url=$DEPLOYMENT_URL" >> $GITHUB_OUTPUT + id: deploy + env: + VERCEL_ORG_ID: ${{ secrets.VERCEL_ORG_ID }} + VERCEL_PROJECT_ID: ${{ secrets.VERCEL_PROJECT_ID }} + VERCEL_TOKEN: ${{ secrets.VERCEL_TOKEN }} + + - name: Comment on Release + uses: actions/github-script@v7 + with: + script: | + const deployment_url = '${{ steps.deploy.outputs.deployment_url }}'; + const { owner, repo } = context.repo; + const release_id = context.payload.release.id; + + await github.rest.repos.updateRelease({ + owner, + repo, + release_id, + body: context.payload.release.body + + '\n\n---\nšŸš€ **Deployed to Production:** ' + deployment_url + }); \ No newline at end of file diff --git a/.gitignore b/.gitignore index 6661ba9..e21866d 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,5 @@ __pycache__ /run/ infrastructure/ nginx/ -prd/ \ No newline at end of file +prd/ +.vercel \ No newline at end of file diff --git a/.release-please-manifest.json b/.release-please-manifest.json new file mode 100644 index 0000000..c04b615 --- /dev/null +++ b/.release-please-manifest.json @@ -0,0 +1,3 @@ +{ + ".": "1.0.0" +} \ No newline at end of file diff --git a/release-please-config.json b/release-please-config.json new file mode 100644 index 0000000..c7f45c5 --- /dev/null +++ b/release-please-config.json @@ -0,0 +1,23 @@ +{ + "packages": { + ".": { + "release-type": "simple", + "package-name": "dograh-copy", + "changelog-sections": [ + {"type": "feat", "section": "Features", "hidden": false}, + {"type": "fix", "section": "Bug Fixes", "hidden": false}, + {"type": "docs", "section": "Documentation", "hidden": false}, + {"type": "perf", "section": "Performance Improvements", "hidden": false}, + {"type": "refactor", "section": "Code Refactoring", "hidden": false}, + {"type": "chore", "section": "Miscellaneous", "hidden": true} + ], + "extra-files": [ + { + "type": "json", + "path": "ui/package.json", + "jsonpath": "$.version" + } + ] + } + } + } \ No newline at end of file diff --git a/ui/package.json b/ui/package.json index b28a05e..0e6183c 100644 --- a/ui/package.json +++ b/ui/package.json @@ -1,6 +1,6 @@ { "name": "ui", - "version": "0.1.0", + "version": "1.0.0", "private": true, "scripts": { "dev": "NODE_OPTIONS='--enable-source-maps' next dev --turbopack",