Skip to content

Commit 180d17e

Browse files
committed
Use a comment
1 parent ecb4029 commit 180d17e

1 file changed

Lines changed: 41 additions & 66 deletions

File tree

.github/workflows/build.yml

Lines changed: 41 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -728,72 +728,47 @@ jobs:
728728
runs-on: ubuntu-latest
729729
if: ${{ always() && needs.deploy.result != 'failed' && github.event_name == 'pull_request' }}
730730
steps:
731-
- name: Create Status Checks with URLs
731+
- name: Generate URLs
732+
id: generate-urls
732733
env:
733-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
734734
PR_NUMBER: ${{ github.event.pull_request.number }}
735735
run: |
736-
# Generate the URLs based on PR number
737-
ALB_ROUTER_URL="https://lambdadispatch-pr-${PR_NUMBER}.ghpublic.pwrdrvr.com"
738-
ALB_DEMOAPP_URL="https://lambdadispatch-demoapp-pr-${PR_NUMBER}.ghpublic.pwrdrvr.com"
739-
NLB_ROUTER_URL="https://lambdadispatch-nlb-pr-${PR_NUMBER}.ghpublic.pwrdrvr.com"
740-
NLB_DEMOAPP_URL="https://lambdadispatch-nlb-demoapp-pr-${PR_NUMBER}.ghpublic.pwrdrvr.com"
741-
742-
# Create deployment statuses for each URL
743-
# ALB Router
744-
gh api repos/${{ github.repository }}/deployments \
745-
-F ref=${{ github.event.pull_request.head.ref }} \
746-
-F environment="ALB Router" \
747-
-F auto_merge=false \
748-
-F required_contexts=[] | jq .id > deployment_id_alb_router.txt
749-
750-
ALB_ROUTER_ID=$(cat deployment_id_alb_router.txt)
751-
gh api repos/${{ github.repository }}/deployments/$ALB_ROUTER_ID/statuses \
752-
-F state=success \
753-
-F environment_url=$ALB_ROUTER_URL \
754-
-F description="ALB Router URL" \
755-
-F log_url=$ALB_ROUTER_URL
756-
757-
# ALB Demo App
758-
gh api repos/${{ github.repository }}/deployments \
759-
-F ref=${{ github.event.pull_request.head.ref }} \
760-
-F environment="ALB Demo App" \
761-
-F auto_merge=false \
762-
-F required_contexts=[] | jq .id > deployment_id_alb_demoapp.txt
763-
764-
ALB_DEMOAPP_ID=$(cat deployment_id_alb_demoapp.txt)
765-
gh api repos/${{ github.repository }}/deployments/$ALB_DEMOAPP_ID/statuses \
766-
-F state=success \
767-
-F environment_url=$ALB_DEMOAPP_URL \
768-
-F description="ALB Demo App URL" \
769-
-F log_url=$ALB_DEMOAPP_URL
770-
771-
# NLB Router
772-
gh api repos/${{ github.repository }}/deployments \
773-
-F ref=${{ github.event.pull_request.head.ref }} \
774-
-F environment="NLB Router" \
775-
-F auto_merge=false \
776-
-F required_contexts=[] | jq .id > deployment_id_nlb_router.txt
777-
778-
NLB_ROUTER_ID=$(cat deployment_id_nlb_router.txt)
779-
gh api repos/${{ github.repository }}/deployments/$NLB_ROUTER_ID/statuses \
780-
-F state=success \
781-
-F environment_url=$NLB_ROUTER_URL \
782-
-F description="NLB Router URL (Port ${PR_NUMBER})" \
783-
-F log_url=$NLB_ROUTER_URL
784-
785-
# NLB Demo App
786-
gh api repos/${{ github.repository }}/deployments \
787-
-F ref=${{ github.event.pull_request.head.ref }} \
788-
-F environment="NLB Demo App" \
789-
-F auto_merge=false \
790-
-F required_contexts=[] | jq .id > deployment_id_nlb_demoapp.txt
791-
792-
NLB_DEMOAPP_ID=$(cat deployment_id_nlb_demoapp.txt)
793-
gh api repos/${{ github.repository }}/deployments/$NLB_DEMOAPP_ID/statuses \
794-
-F state=success \
795-
-F environment_url=$NLB_DEMOAPP_URL \
796-
-F description="NLB Demo App URL (Port ${PR_NUMBER}+10000)" \
797-
-F log_url=$NLB_DEMOAPP_URL
798-
799-
echo "Created deployment status checks with URLs for all endpoints"
736+
echo "alb_router=https://lambdadispatch-pr-${PR_NUMBER}.ghpublic.pwrdrvr.com" >> $GITHUB_OUTPUT
737+
echo "alb_demoapp=https://lambdadispatch-demoapp-pr-${PR_NUMBER}.ghpublic.pwrdrvr.com" >> $GITHUB_OUTPUT
738+
echo "nlb_router=https://lambdadispatch-nlb-pr-${PR_NUMBER}.ghpublic.pwrdrvr.com" >> $GITHUB_OUTPUT
739+
echo "nlb_demoapp=https://lambdadispatch-nlb-demoapp-pr-${PR_NUMBER}.ghpublic.pwrdrvr.com" >> $GITHUB_OUTPUT
740+
741+
- name: Find Deployment URLs Comment
742+
uses: peter-evans/find-comment@v3
743+
id: find-comment
744+
with:
745+
issue-number: ${{ github.event.pull_request.number }}
746+
comment-author: 'github-actions[bot]'
747+
body-includes: '### 🚀 Deployment URLs'
748+
749+
- name: Post Deployment URLs Comment
750+
uses: peter-evans/create-or-update-comment@v4
751+
with:
752+
comment-id: ${{ steps.find-comment.outputs.comment-id }}
753+
edit-mode: replace
754+
issue-number: ${{ github.event.pull_request.number }}
755+
body: |
756+
### 🚀 Deployment URLs
757+
758+
#### Application Load Balancer (ALB)
759+
- **Router**: [${{ steps.generate-urls.outputs.alb_router }}](${{ steps.generate-urls.outputs.alb_router }})
760+
- **Demo App**: [${{ steps.generate-urls.outputs.alb_demoapp }}](${{ steps.generate-urls.outputs.alb_demoapp }})
761+
762+
#### Network Load Balancer (NLB)
763+
- **Router (Port ${{ github.event.pull_request.number }})**: [${{ steps.generate-urls.outputs.nlb_router }}](${{ steps.generate-urls.outputs.nlb_router }})
764+
- **Demo App (Port ${{ github.event.pull_request.number }}+10000)**: [${{ steps.generate-urls.outputs.nlb_demoapp }}](${{ steps.generate-urls.outputs.nlb_demoapp }})
765+
766+
*Deployment updated: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}*
767+
768+
# Create a single environment for the main deployment URL to show in PR checks
769+
- name: Update Main Environment
770+
env:
771+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
772+
run: |
773+
# This will update the environment URL that appears in the PR checks
774+
echo "Deployment URLs have been posted as a comment"

0 commit comments

Comments
 (0)