ci(workflows): add release and deployment automation

This commit is contained in:
Sabiha Khan 2025-10-08 15:38:05 +05:30
parent 3babb5ced6
commit 0e9432b5ff
7 changed files with 117 additions and 7 deletions

View file

@ -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:

View file

@ -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 }}

View file

@ -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
});