11name : Auto Update Version and Build
22
33on :
4- push :
4+ pull_request :
5+ types : [opened, synchronize, reopened]
56 branches :
67 - master
78 - main
1718 permissions :
1819 contents : write
1920 packages : write
20- # Skip if the commit message contains the auto-increment marker to prevent infinite loops
21- if : " !contains(github.event.head_commit.message, '🤖 Auto-increment version')"
21+ # Only run for collaborators or repository owner
22+ if : |
23+ github.event.pull_request.author_association == 'OWNER' ||
24+ github.event.pull_request.author_association == 'COLLABORATOR' ||
25+ github.event.pull_request.author_association == 'MEMBER'
2226
2327 steps :
2428 - name : Checkout repository
5761 echo "changes=false" >> $GITHUB_OUTPUT
5862 fi
5963
60- - name : Commit version changes
64+ - name : Commit version changes (PR only - no push)
6165 if : steps.git_status.outputs.changes == 'true'
6266 run : |
6367 git config --local user.email "action@github.com"
7276 fi
7377
7478 git commit -m "🤖 Auto-increment version to ${{ steps.version_update.outputs.new_version }} (prod: ${{ steps.version_update.outputs.prod_version }}, dev: ${{ steps.version_update.outputs.dev_version }})"
75- git push
79+ # Note: Not pushing changes in PR context - they will be available for review
7680
7781 - name : Log in to the Container registry
7882 uses : docker/login-action@v3
@@ -87,13 +91,10 @@ jobs:
8791 with :
8892 images : ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
8993 tags : |
90- type=raw,value=latest
91- type=raw,value=${{ steps.version_update.outputs.new_version }}
92- type=raw,value=${{ steps.version_update.outputs.prod_version }},enable={{isBranch 'master'}}
93- type=ref,event=branch
94+ type=raw,value=pr-${{ github.event.number }}
95+ type=raw,value=${{ steps.version_update.outputs.new_version }}-pr-${{ github.event.number }}
9496 type=ref,event=pr
95- type=semver,pattern={{version}}
96- type=sha,prefix=
97+ type=sha,prefix=pr-${{ github.event.number }}-
9798
9899 - name : Set up Docker Buildx
99100 uses : docker/setup-buildx-action@v3
@@ -108,68 +109,46 @@ jobs:
108109 cache-from : type=gha
109110 cache-to : type=gha,mode=max
110111
111- - name : Create version branch (stable releases only)
112- if : steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
113- run : |
114- # Create a new branch for this stable version
115- git checkout -b "release/v${{ steps.version_update.outputs.new_version }}"
116- git push origin "release/v${{ steps.version_update.outputs.new_version }}"
117-
118- # Switch back to main branch
119- git checkout ${{ github.ref_name }}
120-
121- - name : Generate release notes (stable releases only)
122- if : steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
123- id : release_notes
124- run : |
125- # Make script executable
126- chmod +x .github/scripts/generate-release-notes.js
112+ - name : Add PR comment with build info
113+ uses : actions/github-script@v7
114+ with :
115+ script : |
116+ const comment = `## 🚀 CI/CD Build Summary for PR #${{ github.event.number }}
127117
128- # Generate release notes using the script
129- node .github/scripts/generate-release-notes.js "${{ steps.version_update.outputs.new_version }}"
118+ **Build Status:** ✅ Success
119+ **Version:** ${{ steps.version_update.outputs.new_version }}
120+ **Docker Images Built:**
121+ - \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ github.event.number }}\`
122+ - \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.new_version }}-pr-${{ github.event.number }}\`
130123
131- - name : Create Git Tag (stable releases only)
132- if : steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
133- run : |
134- git tag v${{ steps.version_update.outputs.new_version }}
135- git push origin v${{ steps.version_update.outputs.new_version }}
124+ **Files Updated:**
125+ - \`apps/web/projectData.ts\` - Updated to ${{ steps.version_update.outputs.new_version }}
126+ - \`version.json\` - prod: ${{ steps.version_update.outputs.prod_version }}, dev: ${{ steps.version_update.outputs.dev_version }}
127+ ${steps.version_update.outputs.version_file ? `- \`Versions/${{ steps.version_update.outputs.version_file }}\` - New version file created` : ''}
136128
137- - name : Create GitHub Release (stable releases only)
138- if : steps.git_status.outputs.changes == 'true' && steps.version_update.outputs.is_stable == 'true' && steps.version_update.outputs.is_master == 'true'
139- env :
140- GITHUB_TOKEN : ${{ secrets.GITHUB_TOKEN }}
141- run : |
142- # Use version file if created, otherwise use generated release notes
143- if [ -f "Versions/${{ steps.version_update.outputs.version_file }}" ]; then
144- NOTES_FILE="Versions/${{ steps.version_update.outputs.version_file }}"
145- else
146- NOTES_FILE="release-notes.md"
147- fi
129+ > **Note:** This is a PR build. No releases or version branches will be created until the PR is merged.`;
148130
149- # Create release using GitHub CLI
150- gh release create v${{ steps.version_update.outputs.new_version }} \
151- --title "Release v${{ steps.version_update.outputs.new_version }}" \
152- --notes-file "$NOTES_FILE" \
153- --latest
131+ github.rest.issues.createComment({
132+ issue_number: context.issue.number,
133+ owner: context.repo.owner,
134+ repo: context.repo.repo,
135+ body: comment
136+ });
154137
155138 - name : Output summary
156139 run : |
157- echo "## 🚀 Comprehensive Version Update & Build Summary " >> $GITHUB_STEP_SUMMARY
140+ echo "## 🚀 PR Build Summary for #${{ github.event.number }} " >> $GITHUB_STEP_SUMMARY
158141 echo "- **Previous version:** ${{ steps.version_update.outputs.previous_version }}" >> $GITHUB_STEP_SUMMARY
159142 echo "- **New version:** ${{ steps.version_update.outputs.new_version }}" >> $GITHUB_STEP_SUMMARY
160143 echo "- **Production version:** ${{ steps.version_update.outputs.prod_version }}" >> $GITHUB_STEP_SUMMARY
161144 echo "- **Development version:** ${{ steps.version_update.outputs.dev_version }}" >> $GITHUB_STEP_SUMMARY
162- echo "- **Branch :** ${{ github.ref_name }}" >> $GITHUB_STEP_SUMMARY
163- echo "- **Stable release :** ${{ steps.version_update.outputs.is_stable }}" >> $GITHUB_STEP_SUMMARY
145+ echo "- **PR Author :** ${{ github.event.pull_request.user.login }}" >> $GITHUB_STEP_SUMMARY
146+ echo "- **Author Association :** ${{ github.event.pull_request.author_association }}" >> $GITHUB_STEP_SUMMARY
164147 echo "" >> $GITHUB_STEP_SUMMARY
165148
166149 echo "### 🐳 Docker Images Built" >> $GITHUB_STEP_SUMMARY
167- echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:latest\`" >> $GITHUB_STEP_SUMMARY
168- echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.new_version }}\`" >> $GITHUB_STEP_SUMMARY
169-
170- if [ "${{ steps.version_update.outputs.is_master }}" == "true" ]; then
171- echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.prod_version }}\`" >> $GITHUB_STEP_SUMMARY
172- fi
150+ echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:pr-${{ github.event.number }}\`" >> $GITHUB_STEP_SUMMARY
151+ echo "- \`${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ steps.version_update.outputs.new_version }}-pr-${{ github.event.number }}\`" >> $GITHUB_STEP_SUMMARY
173152 echo "" >> $GITHUB_STEP_SUMMARY
174153
175154 echo "### 📁 Files Updated" >> $GITHUB_STEP_SUMMARY
@@ -181,19 +160,7 @@ jobs:
181160 fi
182161 echo "" >> $GITHUB_STEP_SUMMARY
183162
184- if [ "${{ steps.version_update.outputs.is_stable }}" == "true" ] && [ "${{ steps.version_update.outputs.is_master }}" == "true" ]; then
185- echo "### 🏷️ Release Created" >> $GITHUB_STEP_SUMMARY
186- echo "- **Tag:** \`v${{ steps.version_update.outputs.new_version }}\`" >> $GITHUB_STEP_SUMMARY
187- echo "- **Branch:** \`release/v${{ steps.version_update.outputs.new_version }}\`" >> $GITHUB_STEP_SUMMARY
188- echo "- **Release:** [v${{ steps.version_update.outputs.new_version }}](https://github.com/${{ github.repository }}/releases/tag/v${{ steps.version_update.outputs.new_version }})" >> $GITHUB_STEP_SUMMARY
189- if [ -n "${{ steps.version_update.outputs.version_file }}" ]; then
190- echo "- **Version File:** \`Versions/${{ steps.version_update.outputs.version_file }}\`" >> $GITHUB_STEP_SUMMARY
191- fi
192- else
193- echo "### ⚠️ Development Build" >> $GITHUB_STEP_SUMMARY
194- if [ "${{ steps.version_update.outputs.is_master }}" != "true" ]; then
195- echo "This is a development branch build. No GitHub release or version branch created." >> $GITHUB_STEP_SUMMARY
196- else
197- echo "This is a pre-release version (contains alpha, beta, canary, etc.). No GitHub release or version branch created." >> $GITHUB_STEP_SUMMARY
198- fi
199- fi
163+ echo "### ℹ️ PR Build Notes" >> $GITHUB_STEP_SUMMARY
164+ echo "This is a pull request build. No releases, tags, or version branches will be created." >> $GITHUB_STEP_SUMMARY
165+ echo "Version changes are committed locally for review but not pushed to the repository." >> $GITHUB_STEP_SUMMARY
166+ echo "Once the PR is merged, you may want to run a separate workflow for production deployments." >> $GITHUB_STEP_SUMMARY
0 commit comments