@@ -12,90 +12,33 @@ concurrency:
1212 cancel-in-progress : false
1313
1414jobs :
15- deploy-dev :
16- name : Deploy to Development
15+ deploy :
16+ name : Deploy to ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && 'Production' || ' Development' }}
1717 runs-on : ubuntu-latest
18- environment : Development
19- # ONLY run for dev branch pushes or PRs targeting dev
20- if : github.ref == 'refs/heads/dev' || (github.event_name == 'pull_request' && github.base_ref == 'dev')
18+ environment : ${{ (github.ref == 'refs/heads/main' || github.base_ref == 'main') && 'Production' || 'Development' }}
2119 permissions :
2220 deployments : write
2321 pull-requests : write
2422 steps :
25- - name : Trigger Render Deploy
26- id : deploy
27- uses : JorgeLNJunior/[email protected] 28- with :
29- service_id : ${{ secrets.RENDER_SERVICE_ID }}
30- api_key : ${{ secrets.RENDER_API_KEY }}
31- wait_deploy : true
32- github_deployment : true
33- deployment_environment : Development
34- github_token : ${{ secrets.GITHUB_TOKEN }}
23+ - name : Set environment name
24+ id : set-env
25+ run : |
26+ if [[ "${{ github.ref }}" == "refs/heads/main" ]] || [[ "${{ github.base_ref }}" == "main" ]]; then
27+ echo "env_name=Production" >> $GITHUB_OUTPUT
28+ echo "env_lower=production" >> $GITHUB_OUTPUT
29+ else
30+ echo "env_name=Development" >> $GITHUB_OUTPUT
31+ echo "env_lower=development" >> $GITHUB_OUTPUT
32+ fi
3533
36- - name : Comment on PR
37- if : github.event_name == 'pull_request'
38- uses : actions/github-script@v7
39- with :
40- github-token : ${{ secrets.GITHUB_TOKEN }}
41- script : |
42- const deployUrl = '${{ secrets.SITE_URL }}';
43- const environment = 'Development';
44- const commentIdentifier = `<!-- deployment-bot:${environment} -->`;
45-
46- const comment = `${commentIdentifier}
47- ### 🚀 Preview Deployment Ready!
48-
49- Your changes have been successfully deployed to the ${environment.toLowerCase()} environment.
50-
51- **Preview URL:** ${deployUrl}
52-
53- | Status | Environment | Commit | Time |
54- |--------|-------------|--------|------|
55- | ✅ Success | ${environment} | \`${context.sha.substring(0, 7)}\` | ${new Date().toISOString()} |
56-
57- ---
58- <sub>🤖 This comment was automatically generated by the deployment workflow.</sub>`;
59-
60- // Find existing comment
61- const { data: comments } = await github.rest.issues.listComments({
62- owner: context.repo.owner,
63- repo: context.repo.repo,
64- issue_number: context.issue.number,
65- });
66-
67- const botComment = comments.find(comment =>
68- comment.body.includes(commentIdentifier)
69- );
70-
71- if (botComment) {
72- // Update existing comment
73- await github.rest.issues.updateComment({
74- owner: context.repo.owner,
75- repo: context.repo.repo,
76- comment_id: botComment.id,
77- body: comment
78- });
79- } else {
80- // Create new comment
81- await github.rest.issues.createComment({
82- issue_number: context.issue.number,
83- owner: context.repo.owner,
84- repo: context.repo.repo,
85- body: comment
86- });
87- }
88-
89- deploy-prod :
90- name : Deploy to Production
91- runs-on : ubuntu-latest
92- environment : Production
93- # ONLY run for main branch pushes or PRs targeting main
94- if : github.ref == 'refs/heads/main' || (github.event_name == 'pull_request' && github.base_ref == 'main')
95- permissions :
96- deployments : write
97- pull-requests : write
98- steps :
34+ - name : Debug - Check Service ID
35+ run : |
36+ echo "Environment: ${{ steps.set-env.outputs.env_name }}"
37+ echo "Service ID length: ${#RENDER_SERVICE_ID}"
38+ echo "Service ID is set: $([[ -n "$RENDER_SERVICE_ID" ]] && echo "Yes" || echo "No")"
39+ env :
40+ RENDER_SERVICE_ID : ${{ secrets.RENDER_SERVICE_ID }}
41+
9942 - name : Trigger Render Deploy
10043 id : deploy
10144 uses :
JorgeLNJunior/[email protected] 10447 api_key : ${{ secrets.RENDER_API_KEY }}
10548 wait_deploy : true
10649 github_deployment : true
107- deployment_environment : Production
50+ deployment_environment : ${{ steps.set-env.outputs.env_name }}
10851 github_token : ${{ secrets.GITHUB_TOKEN }}
10952
11053 - name : Comment on PR
@@ -114,23 +57,21 @@ jobs:
11457 github-token : ${{ secrets.GITHUB_TOKEN }}
11558 script : |
11659 const deployUrl = '${{ secrets.SITE_URL }}';
117- const environment = 'Production ';
60+ const environment = '${{ steps.set-env.outputs.env_name }} ';
11861 const commentIdentifier = `<!-- deployment-bot:${environment} -->`;
11962
12063 const comment = `${commentIdentifier}
121- ### 🚀 Production Preview Deployment Ready!
64+ ### 🚀 ${environment === ' Production' ? 'Production Preview' : 'Preview'} Deployment Ready!
12265
123- Your changes have been successfully deployed to the ${environment.toLowerCase()} preview environment.
66+ Your changes have been successfully deployed to the ${environment.toLowerCase()} ${environment === 'Production' ? ' preview ' : ''} environment.
12467
12568 **Preview URL:** ${deployUrl}
12669
12770 | Status | Environment | Commit | Time |
12871 |--------|-------------|--------|------|
12972 | ✅ Success | ${environment} | \`${context.sha.substring(0, 7)}\` | ${new Date().toISOString()} |
13073
131- ⚠️ **Note:** This is a preview deployment for the production environment. The actual production deployment will occur after merge.
132-
133- ---
74+ ${environment === 'Production' ? '⚠️ **Note:** This is a preview deployment for the production environment. The actual production deployment will occur after merge.\n\n' : ''}---
13475 <sub>🤖 This comment was automatically generated by the deployment workflow.</sub>`;
13576
13677 // Find existing comment
0 commit comments