Skip to content

Commit

Permalink
Merge pull request #745 from 0xPolygon/SPEC-170-deployment-fix
Browse files Browse the repository at this point in the history
Consistent deployment update
  • Loading branch information
sshrihar authored Sep 25, 2024
2 parents de34572 + 3c48a65 commit 64997e6
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 9 deletions.
18 changes: 13 additions & 5 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,31 @@ jobs:
run: |
changed_files=$(git diff --name-only HEAD^ HEAD)
num_changed_files=$(echo "$changed_files" | wc -l)
echo "Number of Files changed=$num_changed_files"
echo "FILES_CHANGED=$num_changed_files" >> "$GITHUB_OUTPUT"
check_pr_open:
runs-on: ubuntu-latest
environment: ${{ inputs.environment }}
needs: [check_files_changed]
if: needs.check_files_changed.outputs.FILES_CHANGED != '' && startsWith(github.ref, 'refs/heads/hosted/')
if: needs.check_files_changed.outputs.FILES_CHANGED != '' && startsWith(github.head_ref, 'hosted/')
permissions:
id-token: write
contents: write
outputs:
PR_OPEN: ${{ steps.check_pr.outputs.PR_OPEN }}
steps:
- name: Checkout Code Repository
uses: actions/checkout@v3
with:
fetch-depth: 1

- name: Check for open PR
id: check_pr
run: |
BRANCH_NAME=$(echo "${GITHUB_REF}" | cut -d'/' -f4)
pr_number=$(gh pr list --head "hosted/$BRANCH_NAME" --state open --json number --jq '.[0].number')
BRANCH_NAME=${{ github.head_ref }}
pr_number=$(gh pr list --head "$BRANCH_NAME" --state open --json number --jq '.[0].number')
echo "Checked PR number: $pr_number"
echo "PR_OPEN=$pr_number" >> "$GITHUB_OUTPUT"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -93,10 +100,11 @@ jobs:
if: |
needs.check_files_changed.outputs.FILES_CHANGED != '' && github.ref == 'refs/heads/dev' ||
needs.check_pr_open.outputs.PR_OPEN != '' && needs.check_files_changed.outputs.FILES_CHANGED != '' &&
startsWith(github.ref, 'refs/heads/hosted/')
startsWith(github.head_ref, 'hosted/')
permissions:
id-token: write
contents: write
pull-requests: write
steps:
- uses: actions/setup-python@v4
with:
Expand Down Expand Up @@ -160,4 +168,4 @@ jobs:
with:
cf_zone: ${{ secrets.CLOUDFLARE_ZONE }}
cf_auth: ${{ secrets.CLOUDFLARE_AUTH_KEY }}
hosts: ${{ inputs.core_app }}-${{ inputs.environment }}.polygon.technology
hosts: ${{ inputs.core_app }}-${{ inputs.environment }}.polygon.technology
3 changes: 1 addition & 2 deletions .github/workflows/hosted-dev-deployment.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
name: Hosted PR and Dev Deployment
on:
pull_request:
types: [opened, edited, reopened]
types: [opened, edited, reopened, synchronize]
push:
branches:
- dev
- hosted/**
workflow_dispatch:

jobs:
Expand Down
5 changes: 3 additions & 2 deletions build_branches.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

import ast
import os
import shutil
Expand Down Expand Up @@ -148,5 +149,5 @@ def update_nginx_config(pr_numbers):

if __name__ == "__main__":
current_dir = os.getcwd()
pr_numbers = process_branch_folders()
update_nginx_config(pr_numbers)
open_prs = process_branch_folders()
update_nginx_config(open_prs)

0 comments on commit 64997e6

Please sign in to comment.