Skip to content

Commit 4c3c606

Browse files
committed
Deployment Fix for main branch
1 parent 4aacff0 commit 4c3c606

File tree

3 files changed

+33
-6
lines changed

3 files changed

+33
-6
lines changed

.github/workflows/build_and_deploy.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ jobs:
5252
with:
5353
fetch-depth: 0
5454

55+
- name: Get list of changed files
56+
id: changes
57+
run: |
58+
changed_files=$(git diff --name-only HEAD^ HEAD)
59+
echo "Changed files: $changed_files"
60+
echo "FILES_CHANGED=$changed_files" >> "$GITHUB_OUTPUT"
61+
62+
- name: Stop if no files changed
63+
if: ${{ steps.changes.outputs.FILES_CHANGED == '' }}
64+
run: |
65+
echo "No files were changed, skipping build."
66+
exit 0
67+
5568
- name: Configure AWS credentials
5669
uses: aws-actions/configure-aws-credentials@v4
5770
with:
@@ -119,4 +132,4 @@ jobs:
119132
with:
120133
cf_zone: ${{ secrets.CLOUDFLARE_ZONE }}
121134
cf_auth: ${{ secrets.CLOUDFLARE_AUTH_KEY }}
122-
hosts: ${{ env.APP_NAME }}.polygon.technology
135+
hosts: ${{ env.APP_NAME }}.polygon.technology

.github/workflows/pr-deployment.yml

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,13 @@ name: hosted branch pr deployment
22
on:
33
pull_request:
44
types: [opened, edited, reopened]
5-
branches:
6-
- hosted/*
75
push:
86
branches:
97
- dev
108
workflow_dispatch:
119

1210
jobs:
1311
deploy:
12+
if: startsWith(github.head_ref, 'hosted/') || github.ref == 'refs/heads/dev'
1413
uses: ./.github/workflows/build_and_deploy.yml
15-
secrets: inherit
16-
14+
secrets: inherit

build_branches.py

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ def clone_data_to_branch_folder(branch_name, remote_url, parent_dir, pr_number=N
7272
os.chdir(parent_dir)
7373

7474

75+
def update_pr_description(pr_number):
76+
"""
77+
Updates PR description by adding the url to access the hosted environment under dev
78+
if it does not already exist in the definition
79+
:param pr_number: PR number for the branch hosting website
80+
"""
81+
command = ["gh", "pr", "view", pr_number, "--json", "body", "--jq", "'.body'"]
82+
pr_description = subprocess.run(command, capture_output=True, text=True).stdout.strip()
83+
hosted_url = f"docs-dev.polygon.technology/{pr_number}"
84+
if hosted_url not in pr_description:
85+
new_pr_description = f"Hosted url: [{hosted_url}](https://{hosted_url})\n" + pr_description
86+
command = ["gh", "pr", "edit", pr_number, "--body", new_pr_description]
87+
subprocess.run(command)
88+
89+
7590
def process_branch_folders():
7691
"""
7792
Clones the branch specific code to hosted/<branch-name> folder.
@@ -95,6 +110,7 @@ def process_branch_folders():
95110
continue
96111
pr_number = str(branch_data["number"])
97112
clone_data_to_branch_folder(branch_data["headRefName"], remote_url, parent_dir, pr_number)
113+
update_pr_description(pr_number)
98114
pr_numbers.append(pr_number)
99115

100116
return pr_numbers
@@ -129,4 +145,4 @@ def update_nginx_config(pr_numbers):
129145
if __name__ == "__main__":
130146
current_dir = os.getcwd()
131147
pr_numbers = process_branch_folders()
132-
update_nginx_config(pr_numbers)
148+
update_nginx_config(pr_numbers)

0 commit comments

Comments
 (0)