-
Notifications
You must be signed in to change notification settings - Fork 1
cicd workflow for deploying the app on azure #11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
e310322
cicd workflow for deploying the app on azure
vipinpaul a7de355
Updated CI/CD pipeline to build and deploy app to Dev (auto) and Prod…
vipinpaul a3a1544
Added CI workflow to validate PRs with linting, tests, type checking,…
vipinpaul abbe45c
Added GitHub Action to automatically delete merged branches
vipinpaul e331343
Update CI to use pnpm instead of npm in PR validation workflow to mat…
vipinpaul a429c1c
Correcting the package script and eslint config
vipinpaul 6bc5dfd
re-configured eslint and prettier
vipinpaul 6da53fa
fixed all linting error
vipinpaul 43e3885
resolving duplicate imports
vipinpaul 9d8184d
migrate from pnpm to npm
vipinpaul 0aa9449
Renamed git actions workflows to match standard conventions
vipinpaul b1c6cc1
avoid this workflow for draft PR
vipinpaul File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,142 @@ | ||
| # Deploys Scribe-server Node.js app to Azure Web Apps after merge | ||
| name: Post-merge-deploy | ||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| workflow_dispatch: | ||
| inputs: | ||
| environment: | ||
| description: Environment to deploy to | ||
| required: true | ||
| default: dev | ||
| type: choice | ||
| options: | ||
| - dev | ||
| - prod | ||
|
|
||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Node.js version | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22.15.0 | ||
| cache: npm | ||
|
|
||
| - name: Install all dependencies | ||
| run: npm install --legacy-peer-deps | ||
|
|
||
| - name: Lint and format check | ||
| run: | | ||
| npm run lint | ||
| npm run format:check | ||
|
|
||
| - name: Type check | ||
| run: npm run typecheck | ||
|
|
||
| - name: Run tests | ||
| run: npm run test | ||
|
|
||
| - name: Build application | ||
| run: npm run build | ||
|
|
||
| - name: Create deployment package directory | ||
| run: | | ||
| mkdir -p deployment | ||
| cp -r dist deployment/ | ||
| cp package.json deployment/ | ||
| cp package-lock.json deployment/ || true | ||
|
|
||
| - name: Install production dependencies | ||
| run: | | ||
| cd deployment | ||
| npm install --prod --legacy-peer-deps | ||
|
|
||
| - name: Upload artifact for deployment job | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: node-app | ||
| path: deployment/ | ||
|
|
||
| deploy-dev: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| if: github.event_name == 'push' || (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'dev') | ||
| environment: | ||
| name: Development | ||
| url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | ||
| steps: | ||
| - name: Download artifact from build job | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: node-app | ||
| path: deployment/ | ||
|
|
||
| - name: Deploy to Azure Web App | ||
| id: deploy-to-webapp | ||
| uses: azure/webapps-deploy@v3 | ||
| with: | ||
| app-name: scribe-server-dev | ||
| publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_947D34B0D69C4986A7E211253893C796 }} | ||
| package: deployment/ | ||
| clean: true | ||
|
|
||
| - name: Verify deployment | ||
| run: | | ||
| sleep 30 | ||
| for i in $(seq 1 10); do | ||
| response=$(curl -s -o /dev/null -w "%{http_code}" ${{ steps.deploy-to-webapp.outputs.webapp-url }}) | ||
| if [ "$response" -ge 200 ] && [ "$response" -lt 400 ]; then | ||
| echo "Dev deployment successful (HTTP $response)" | ||
| exit 0 | ||
| else | ||
| echo "App not ready yet (HTTP $response). Retrying in 10 seconds..." | ||
| sleep 10 | ||
| fi | ||
| done | ||
| echo "Dev deployment verification failed" | ||
| exit 1 | ||
|
|
||
| deploy-prod: | ||
| runs-on: ubuntu-latest | ||
| needs: build | ||
| if: github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'prod' | ||
| environment: | ||
| name: Production | ||
| url: ${{ steps.deploy-to-webapp.outputs.webapp-url }} | ||
| steps: | ||
| - name: Download artifact from build job | ||
| uses: actions/download-artifact@v4 | ||
| with: | ||
| name: node-app | ||
| path: deployment/ | ||
|
|
||
| - name: Deploy to Azure Web App | ||
| id: deploy-to-webapp | ||
| uses: azure/webapps-deploy@v3 | ||
| with: | ||
| app-name: scribe-server-prod | ||
| publish-profile: ${{ secrets.AZUREAPPSERVICE_PUBLISHPROFILE_PROD }} | ||
| package: deployment/ | ||
| clean: true | ||
|
|
||
| - name: Verify deployment | ||
| run: | | ||
| sleep 45 | ||
| for i in $(seq 1 12); do | ||
| response=$(curl -s -o /dev/null -w "%{http_code}" ${{ steps.deploy-to-webapp.outputs.webapp-url }}) | ||
| if [ "$response" -ge 200 ] && [ "$response" -lt 400 ]; then | ||
| echo "Production deployment successful (HTTP $response)" | ||
| exit 0 | ||
| else | ||
| echo "App not ready yet (HTTP $response). Retrying in 15 seconds..." | ||
| sleep 15 | ||
| fi | ||
| done | ||
| echo "Production deployment verification failed" | ||
| exit 1 |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| # Auto-cleanup merged branches after PR is closed | ||
| name: PR closed | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [closed] | ||
|
|
||
| jobs: | ||
| cleanup: | ||
| if: github.event.pull_request.merged == true | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Delete merged branch | ||
| uses: dawidd6/action-delete-branch@v3 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| branches: ${{ github.event.pull_request.head.ref }} |
This file contains hidden or 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| # Validates Pull Requests by running linting, testing, and type checking | ||
| name: Pre-merge | ||
| on: | ||
| pull_request: | ||
| types: [opened, synchronize, reopened, ready_for_review] | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| validate: | ||
| runs-on: ubuntu-latest | ||
| if: ${{ !github.event.pull_request.draft }} | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
|
|
||
| - name: Set up Node.js version | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 22.15.0 | ||
| cache: npm | ||
|
|
||
| - name: Install dependencies | ||
| run: npm install --legacy-peer-deps | ||
|
|
||
| - name: Lint and format check | ||
| run: | | ||
| npm run lint | ||
| npm run format:check | ||
|
|
||
| - name: Type check | ||
| run: npm run typecheck | ||
|
|
||
| - name: Run tests | ||
| run: npm run test | ||
|
|
||
| - name: Build test | ||
| run: npm run build | ||
This file contains hidden or 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
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.