Merge pull request #132 from netwrix/ssk/pgflashnetsuite-notes #283
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
| name: Deploy to Render | |
| on: | |
| push: | |
| branches: [dev, main] | |
| pull_request: | |
| branches: [dev, main] | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: 'Environment to deploy to' | |
| required: true | |
| default: 'development' | |
| type: choice | |
| options: | |
| - development | |
| - production | |
| # Prevent multiple concurrent deployments | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| deploy-dev: | |
| name: Deploy to Development | |
| runs-on: ubuntu-latest | |
| environment: Development | |
| # Run for: dev branch pushes, PRs targeting dev, or manual dispatch to development | |
| if: | | |
| github.ref == 'refs/heads/dev' || | |
| (github.event_name == 'pull_request' && github.base_ref == 'dev') || | |
| (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'development') | |
| permissions: | |
| deployments: write | |
| pull-requests: write | |
| steps: | |
| - name: Trigger Render Deploy | |
| id: deploy | |
| uses: JorgeLNJunior/[email protected] | |
| with: | |
| service_id: ${{ vars.RENDER_SERVICE_ID }} | |
| api_key: ${{ secrets.RENDER_API_KEY }} | |
| clear_cache: false | |
| wait_deploy: true | |
| github_deployment: true | |
| deployment_environment: ${{ vars.RENDER_DEPLOY_ENVIRONMENT }} | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Comment on PR | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const deployUrl = '${{ vars.SITE_URL }}'; | |
| const environment = 'Development'; | |
| const commentIdentifier = `<!-- deployment-bot:${environment} -->`; | |
| const comment = `${commentIdentifier} | |
| ### 🚀 Preview Deployment Ready! | |
| Your changes have been successfully deployed to the ${environment.toLowerCase()} environment. | |
| **Preview URL:** ${deployUrl} | |
| | Status | Environment | Commit | Time | | |
| |--------|-------------|--------|------| | |
| | ✅ Success | ${environment} | \`${context.sha.substring(0, 7)}\` | ${new Date().toISOString()} | | |
| --- | |
| <sub>🤖 This comment was automatically generated by the deployment workflow.</sub>`; | |
| // Find existing comment | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const botComment = comments.find(comment => | |
| comment.body.includes(commentIdentifier) | |
| ); | |
| if (botComment) { | |
| // Update existing comment | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: comment | |
| }); | |
| } else { | |
| // Create new comment | |
| await github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); | |
| } | |
| deploy-prod: | |
| name: Deploy to Production | |
| runs-on: ubuntu-latest | |
| environment: Production | |
| # Run for: main branch pushes, PRs targeting main, or manual dispatch to production | |
| if: | | |
| github.ref == 'refs/heads/main' || | |
| (github.event_name == 'pull_request' && github.base_ref == 'main') || | |
| (github.event_name == 'workflow_dispatch' && github.event.inputs.environment == 'production') | |
| permissions: | |
| deployments: write | |
| pull-requests: write | |
| steps: | |
| - name: Trigger Render Deploy | |
| id: deploy | |
| uses: JorgeLNJunior/[email protected] | |
| with: | |
| service_id: ${{ vars.RENDER_SERVICE_ID }} | |
| api_key: ${{ secrets.RENDER_API_KEY }} | |
| clear_cache: false | |
| wait_deploy: true | |
| github_deployment: true | |
| deployment_environment: ${{ vars.RENDER_DEPLOY_ENVIRONMENT }} | |
| github_token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Comment on PR | |
| if: github.event_name == 'pull_request' | |
| uses: actions/github-script@v7 | |
| with: | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| script: | | |
| const deployUrl = '${{ vars.SITE_URL }}'; | |
| const environment = 'Production'; | |
| const commentIdentifier = `<!-- deployment-bot:${environment} -->`; | |
| const comment = `${commentIdentifier} | |
| ### 🚀 Production Preview Deployment Ready! | |
| Your changes have been successfully deployed to the ${environment.toLowerCase()} preview environment. | |
| **Preview URL:** ${deployUrl} | |
| | Status | Environment | Commit | Time | | |
| |--------|-------------|--------|------| | |
| | ✅ Success | ${environment} | \`${context.sha.substring(0, 7)}\` | ${new Date().toISOString()} | | |
| ⚠️ **Note:** This is a preview deployment for the production environment. The actual production deployment will occur after merge. | |
| --- | |
| <sub>🤖 This comment was automatically generated by the deployment workflow.</sub>`; | |
| // Find existing comment | |
| const { data: comments } = await github.rest.issues.listComments({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| issue_number: context.issue.number, | |
| }); | |
| const botComment = comments.find(comment => | |
| comment.body.includes(commentIdentifier) | |
| ); | |
| if (botComment) { | |
| // Update existing comment | |
| await github.rest.issues.updateComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| comment_id: botComment.id, | |
| body: comment | |
| }); | |
| } else { | |
| // Create new comment | |
| await github.rest.issues.createComment({ | |
| issue_number: context.issue.number, | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| body: comment | |
| }); | |
| } |