diff --git a/.github/workflows/dev_deployment.yml b/.github/workflows/dev_deployment.yml deleted file mode 100644 index 7f8c664c5..000000000 --- a/.github/workflows/dev_deployment.yml +++ /dev/null @@ -1,92 +0,0 @@ -name: Docs Dev Deployment -on: - #schedule: - # - cron: '0 */12 * * *' - push: - branches: ['dev'] - pull_request: - branches: ['dev'] - workflow_dispatch: - -jobs: - deploy_staging: - name: Dev Deployment - permissions: - id-token: write - contents: write - environment: dev - runs-on: ubuntu-latest - env: - AWS_REGION: eu-west-1 - ECR_REPOSITORY: docs-dev-ecr - ECS_SERVICE: docs-dev-ecs-service - ECS_CLUSTER: frontend-dev-ecs-cluster - ECS_TASK_DEFINITION: .github/assets/dev-taskdef.json - CONTAINER_NAME: docs-dev - steps: - - name: Checkout - uses: actions/checkout@v3 - with: - #ref: dev - fetch-depth: 0 - submodules: true - - - name: Verify branch - run: | - echo "Current branch: $(git rev-parse --abbrev-ref HEAD)" - echo "GitHub ref: ${{ github.ref }}" - - - name: Configure AWS credentials - uses: aws-actions/configure-aws-credentials@v1-node16 - with: - aws-region: ${{ env.AWS_REGION }} - role-to-assume: arn:aws:iam::058264511034:role/docs-dev-GithubActionsRole - role-session-name: GithubActionsSession - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - - - name: Use Python - uses: actions/setup-python@v4 - with: - python-version: '3.12' - - - name: pip Install - run: pip install -r requirements.txt --no-cache-dir - - - name: Build mkdocs - run: mkdocs build - - - name: Build, tag, and push image to Amazon ECR - id: build-image - env: - ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} - IMAGE_TAG: ${{ github.sha }}-${{ github.run_number }} - run: | - docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG -f .github/assets/Dockerfile.nginx . - docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG - echo "image=$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" >> $GITHUB_OUTPUT - - - name: Fill in the new image ID in the Amazon ECS task definition - id: task-def - uses: aws-actions/amazon-ecs-render-task-definition@v1 - with: - task-definition: ${{ env.ECS_TASK_DEFINITION }} - container-name: ${{ env.CONTAINER_NAME }} - image: ${{ steps.build-image.outputs.image }} - - - name: Deploy Amazon ECS task definition - uses: aws-actions/amazon-ecs-deploy-task-definition@v1 - with: - task-definition: ${{ steps.task-def.outputs.task-definition }} - service: ${{ env.ECS_SERVICE }} - cluster: ${{ env.ECS_CLUSTER }} - wait-for-service-stability: true - - - name: Cloudflare Cache Purge - uses: nathanvaughn/actions-cloudflare-purge@master - with: - cf_zone: ${{ secrets.CLOUDFLARE_ZONE }} - cf_auth: ${{ secrets.CLOUDFLARE_AUTH_KEY }} - hosts: docs-dev.polygon.technology diff --git a/.github/workflows/pr-deployment.yml b/.github/workflows/hosted-dev-deployment.yml similarity index 86% rename from .github/workflows/pr-deployment.yml rename to .github/workflows/hosted-dev-deployment.yml index d07299551..849749a59 100644 --- a/.github/workflows/pr-deployment.yml +++ b/.github/workflows/hosted-dev-deployment.yml @@ -1,4 +1,4 @@ -name: Hosted PR Deployment +name: Hosted PR and Dev Deployment on: pull_request: types: [opened, edited, reopened] diff --git a/build_branches.py b/build_branches.py index 9c8d6cf69..d24538f6e 100755 --- a/build_branches.py +++ b/build_branches.py @@ -4,6 +4,9 @@ import subprocess +HOSTED_SITE_DOMAIN = "docs-dev.polygon.technology" + + def install_mkdocs_with_pipenv(): """ Builds a particular branch site. @@ -78,9 +81,9 @@ def update_pr_description(pr_number): if it does not already exist in the definition :param pr_number: PR number for the branch hosting website """ - command = ["gh", "pr", "view", pr_number, "--json", "body", "--jq", "'.body'"] + command = ["gh", "pr", "view", pr_number, "--json", "body", "--jq", ".body"] pr_description = subprocess.run(command, capture_output=True, text=True).stdout.strip() - hosted_url = f"docs-dev.polygon.technology/{pr_number}" + hosted_url = f"{HOSTED_SITE_DOMAIN}/{pr_number}" if hosted_url not in pr_description: new_pr_description = f"Hosted url: [{hosted_url}](https://{hosted_url})\n" + pr_description command = ["gh", "pr", "edit", pr_number, "--body", new_pr_description] @@ -132,6 +135,7 @@ def update_nginx_config(pr_numbers): }} """ nginx_location_blocks += location_block + print(f"Hosted site: https://{HOSTED_SITE_DOMAIN}/{pr_number}") with open(config_file, "r+") as f: content = f.read()