From f2f67de0097dee6559f258d209bcb00b24aff348 Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Fri, 31 Jan 2025 06:19:47 -0700 Subject: [PATCH 1/2] re-indent uffizi yaml files --- .github/uffizzi/docker-compose.uffizzi.yml | 34 ++--- .github/workflows/uffizzi-build.yml | 145 +++++++++--------- .github/workflows/uffizzi-preview.yml | 170 ++++++++++----------- 3 files changed, 175 insertions(+), 174 deletions(-) diff --git a/.github/uffizzi/docker-compose.uffizzi.yml b/.github/uffizzi/docker-compose.uffizzi.yml index 306a817125..4b908af16c 100644 --- a/.github/uffizzi/docker-compose.uffizzi.yml +++ b/.github/uffizzi/docker-compose.uffizzi.yml @@ -1,22 +1,22 @@ version: "3" x-uffizzi: - ingress: - service: online-go - port: 8080 + ingress: + service: online-go + port: 8080 services: - online-go: - image: '${ONLINE_GO_IMAGE}' - environment: - #OGS_BACKEND: PRODUCTION - OGS_BACKEND: BETA - # entrypoint: - # - "sh" - # command: - # - "-c" - # - "npm run dev" - deploy: - resources: - limits: - memory: 4000M + online-go: + image: "${ONLINE_GO_IMAGE}" + environment: + #OGS_BACKEND: PRODUCTION + OGS_BACKEND: BETA + # entrypoint: + # - "sh" + # command: + # - "-c" + # - "npm run dev" + deploy: + resources: + limits: + memory: 4000M diff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.yml index 3a1270c498..32442bf898 100644 --- a/.github/workflows/uffizzi-build.yml +++ b/.github/workflows/uffizzi-build.yml @@ -1,81 +1,82 @@ name: Preview (build) + on: - pull_request: - types: [opened,synchronize,reopened,closed] + pull_request: + types: [opened, synchronize, reopened, closed] jobs: - build-online-go: - name: Build and Push `online-go` - runs-on: ubuntu-latest - if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }} - outputs: - tags: ${{ steps.meta.outputs.tags }} - steps: - - name: checkout - uses: actions/checkout@v3 - - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 + build-online-go: + name: Build and Push `online-go` + runs-on: ubuntu-latest + if: ${{ github.event_name != 'pull_request' || github.event.action != 'closed' }} + outputs: + tags: ${{ steps.meta.outputs.tags }} + steps: + - name: checkout + uses: actions/checkout@v3 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v2 - - name: Generate UUID image name - id: uuid - run: echo "UUID_TAG_APP=online-go-$(uuidgen --time)" >> $GITHUB_ENV + - name: Generate UUID image name + id: uuid + run: echo "UUID_TAG_APP=online-go-$(uuidgen --time)" >> $GITHUB_ENV - - name: Docker metadata - id: meta - uses: docker/metadata-action@v4 - with: - images: registry.uffizzi.com/${{ env.UUID_TAG_APP }} - tags: type=raw,value=30d + - name: Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: registry.uffizzi.com/${{ env.UUID_TAG_APP }} + tags: type=raw,value=30d - - name: Build Image - uses: docker/build-push-action@v3 - with: - push: true - context: ./ - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} - cache-from: type=gha - cache-to: type=gha,mode=max + - name: Build Image + uses: docker/build-push-action@v3 + with: + push: true + context: ./ + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max - render-compose-file: - name: Render Docker Compose File - runs-on: ubuntu-latest - needs: - - build-online-go - outputs: - compose-file-cache-key: ${{ steps.hash.outputs.hash }} - steps: - - name: Checkout git repo - uses: actions/checkout@v3 - - name: Render Compose File - run: | - ONLINE_GO_IMAGE=${{ needs.build-online-go.outputs.tags }} - export ONLINE_GO_IMAGE - envsubst '${ONLINE_GO_IMAGE}' < ./.github/uffizzi/docker-compose.uffizzi.yml > docker-compose.rendered.yml - cat docker-compose.rendered.yml - - name: Upload Rendered Compose File as Artifact - uses: actions/upload-artifact@v3 - with: - name: preview-spec - path: docker-compose.rendered.yml - retention-days: 2 - - name: Upload PR Event as Artifact - uses: actions/upload-artifact@v3 - with: - name: preview-spec - path: ${{ github.event_path }} - retention-days: 2 + render-compose-file: + name: Render Docker Compose File + runs-on: ubuntu-latest + needs: + - build-online-go + outputs: + compose-file-cache-key: ${{ steps.hash.outputs.hash }} + steps: + - name: Checkout git repo + uses: actions/checkout@v3 + - name: Render Compose File + run: | + ONLINE_GO_IMAGE=${{ needs.build-online-go.outputs.tags }} + export ONLINE_GO_IMAGE + envsubst '${ONLINE_GO_IMAGE}' < ./.github/uffizzi/docker-compose.uffizzi.yml > docker-compose.rendered.yml + cat docker-compose.rendered.yml + - name: Upload Rendered Compose File as Artifact + uses: actions/upload-artifact@v3 + with: + name: preview-spec + path: docker-compose.rendered.yml + retention-days: 2 + - name: Upload PR Event as Artifact + uses: actions/upload-artifact@v3 + with: + name: preview-spec + path: ${{ github.event_path }} + retention-days: 2 - delete-preview: - name: Call for Preview Deletion - runs-on: ubuntu-latest - if: ${{ github.event.action == 'closed' }} - steps: - # If this PR is closing, we will not render a compose file nor pass it to the next workflow. - - name: Upload PR Event as Artifact - uses: actions/upload-artifact@v3 - with: - name: preview-spec - path: ${{ github.event_path }} - retention-days: 2 + delete-preview: + name: Call for Preview Deletion + runs-on: ubuntu-latest + if: ${{ github.event.action == 'closed' }} + steps: + # If this PR is closing, we will not render a compose file nor pass it to the next workflow. + - name: Upload PR Event as Artifact + uses: actions/upload-artifact@v3 + with: + name: preview-spec + path: ${{ github.event_path }} + retention-days: 2 diff --git a/.github/workflows/uffizzi-preview.yml b/.github/workflows/uffizzi-preview.yml index 9ca6936c45..7d7074f8b7 100644 --- a/.github/workflows/uffizzi-preview.yml +++ b/.github/workflows/uffizzi-preview.yml @@ -1,96 +1,96 @@ name: Preview (deploy) on: - workflow_run: - workflows: - - 'Preview (build)' - types: - - completed + workflow_run: + workflows: + - "Preview (build)" + types: + - completed jobs: - cache-compose-file: - name: Cache Compose File - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - outputs: - compose-file-cache-key: ${{ steps.hash.outputs.COMPOSE_FILE_HASH }} - git-ref: ${{ steps.event.outputs.GIT_REF }} - pr-number: ${{ steps.event.outputs.PR_NUMBER }} - action: ${{ steps.event.outputs.ACTION }} - steps: - - name: 'Download artifacts' - # Fetch output (zip archive) from the workflow run that triggered this workflow. - uses: actions/github-script@v6 - with: - script: | - let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ - owner: context.repo.owner, - repo: context.repo.repo, - run_id: context.payload.workflow_run.id, - }); - let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "preview-spec" - })[0]; - if (matchArtifact === undefined) { - throw TypeError('Build Artifact not found!'); - } - let download = await github.rest.actions.downloadArtifact({ - owner: context.repo.owner, - repo: context.repo.repo, - artifact_id: matchArtifact.id, - archive_format: 'zip', - }); - let fs = require('fs'); - fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/preview-spec.zip`, Buffer.from(download.data)); + cache-compose-file: + name: Cache Compose File + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + outputs: + compose-file-cache-key: ${{ steps.hash.outputs.COMPOSE_FILE_HASH }} + git-ref: ${{ steps.event.outputs.GIT_REF }} + pr-number: ${{ steps.event.outputs.PR_NUMBER }} + action: ${{ steps.event.outputs.ACTION }} + steps: + - name: "Download artifacts" + # Fetch output (zip archive) from the workflow run that triggered this workflow. + uses: actions/github-script@v6 + with: + script: | + let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({ + owner: context.repo.owner, + repo: context.repo.repo, + run_id: context.payload.workflow_run.id, + }); + let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { + return artifact.name == "preview-spec" + })[0]; + if (matchArtifact === undefined) { + throw TypeError('Build Artifact not found!'); + } + let download = await github.rest.actions.downloadArtifact({ + owner: context.repo.owner, + repo: context.repo.repo, + artifact_id: matchArtifact.id, + archive_format: 'zip', + }); + let fs = require('fs'); + fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/preview-spec.zip`, Buffer.from(download.data)); - - name: 'Accept event from first stage' - run: unzip preview-spec.zip event.json + - name: "Accept event from first stage" + run: unzip preview-spec.zip event.json - - name: Read Event into ENV - id: event - run: | - echo PR_NUMBER=$(jq '.number | tonumber' < event.json) >> $GITHUB_OUTPUT - echo ACTION=$(jq --raw-output '.action | tostring | [scan("\\w+")][0]' < event.json) >> $GITHUB_OUTPUT - echo GIT_REF=$(jq --raw-output '.pull_request.head.sha | tostring | [scan("\\w+")][0]' < event.json) >> $GITHUB_OUTPUT + - name: Read Event into ENV + id: event + run: | + echo PR_NUMBER=$(jq '.number | tonumber' < event.json) >> $GITHUB_OUTPUT + echo ACTION=$(jq --raw-output '.action | tostring | [scan("\\w+")][0]' < event.json) >> $GITHUB_OUTPUT + echo GIT_REF=$(jq --raw-output '.pull_request.head.sha | tostring | [scan("\\w+")][0]' < event.json) >> $GITHUB_OUTPUT - - name: Hash Rendered Compose File - id: hash - # If the previous workflow was triggered by a PR close event, we will not have a compose file artifact. - if: ${{ steps.event.outputs.ACTION != 'closed' }} - run: | - unzip preview-spec.zip docker-compose.rendered.yml - echo "COMPOSE_FILE_HASH=$(md5sum docker-compose.rendered.yml | awk '{ print $1 }')" >> $GITHUB_OUTPUT + - name: Hash Rendered Compose File + id: hash + # If the previous workflow was triggered by a PR close event, we will not have a compose file artifact. + if: ${{ steps.event.outputs.ACTION != 'closed' }} + run: | + unzip preview-spec.zip docker-compose.rendered.yml + echo "COMPOSE_FILE_HASH=$(md5sum docker-compose.rendered.yml | awk '{ print $1 }')" >> $GITHUB_OUTPUT - - name: Cache Rendered Compose File - if: ${{ steps.event.outputs.ACTION != 'closed' }} - uses: actions/cache@v4 - with: - path: docker-compose.rendered.yml - key: ${{ steps.hash.outputs.COMPOSE_FILE_HASH }} + - name: Cache Rendered Compose File + if: ${{ steps.event.outputs.ACTION != 'closed' }} + uses: actions/cache@v4 + with: + path: docker-compose.rendered.yml + key: ${{ steps.hash.outputs.COMPOSE_FILE_HASH }} - - name: DEBUG - Print Job Outputs - if: ${{ runner.debug }} - run: | - echo "PR number: ${{ steps.event.outputs.PR_NUMBER }}" - echo "Git Ref: ${{ steps.event.outputs.GIT_REF }}" - echo "Action: ${{ steps.event.outputs.ACTION }}" - echo "Compose file hash: ${{ steps.hash.outputs.COMPOSE_FILE_HASH }}" - cat event.json + - name: DEBUG - Print Job Outputs + if: ${{ runner.debug }} + run: | + echo "PR number: ${{ steps.event.outputs.PR_NUMBER }}" + echo "Git Ref: ${{ steps.event.outputs.GIT_REF }}" + echo "Action: ${{ steps.event.outputs.ACTION }}" + echo "Compose file hash: ${{ steps.hash.outputs.COMPOSE_FILE_HASH }}" + cat event.json - deploy-uffizzi-preview: - name: Use Remote Workflow to Preview on Uffizzi - needs: - - cache-compose-file - if: ${{ github.event.workflow_run.conclusion == 'success' }} - uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2 - with: - # If this workflow was triggered by a PR close event, cache-key will be an empty string - # and this reusable workflow will delete the preview deployment. - compose-file-cache-key: ${{ needs.cache-compose-file.outputs.compose-file-cache-key }} - compose-file-cache-path: docker-compose.rendered.yml - server: https://app.uffizzi.com - pr-number: ${{ needs.cache-compose-file.outputs.pr-number }} - permissions: - contents: read - pull-requests: write - id-token: write + deploy-uffizzi-preview: + name: Use Remote Workflow to Preview on Uffizzi + needs: + - cache-compose-file + if: ${{ github.event.workflow_run.conclusion == 'success' }} + uses: UffizziCloud/preview-action/.github/workflows/reusable.yaml@v2 + with: + # If this workflow was triggered by a PR close event, cache-key will be an empty string + # and this reusable workflow will delete the preview deployment. + compose-file-cache-key: ${{ needs.cache-compose-file.outputs.compose-file-cache-key }} + compose-file-cache-path: docker-compose.rendered.yml + server: https://app.uffizzi.com + pr-number: ${{ needs.cache-compose-file.outputs.pr-number }} + permissions: + contents: read + pull-requests: write + id-token: write From f84d696626c6eedd765a8ffa9cd7ebcdcc26cf8d Mon Sep 17 00:00:00 2001 From: Akita Noek Date: Fri, 31 Jan 2025 06:30:53 -0700 Subject: [PATCH 2/2] Attempt 1 at fixing uffizi --- .github/workflows/uffizzi-build.yml | 14 +++++++------- .github/workflows/uffizzi-preview.yml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/.github/workflows/uffizzi-build.yml b/.github/workflows/uffizzi-build.yml index 32442bf898..a8d90bcb7c 100644 --- a/.github/workflows/uffizzi-build.yml +++ b/.github/workflows/uffizzi-build.yml @@ -48,7 +48,7 @@ jobs: compose-file-cache-key: ${{ steps.hash.outputs.hash }} steps: - name: Checkout git repo - uses: actions/checkout@v3 + uses: actions/checkout@v4 - name: Render Compose File run: | ONLINE_GO_IMAGE=${{ needs.build-online-go.outputs.tags }} @@ -56,15 +56,15 @@ jobs: envsubst '${ONLINE_GO_IMAGE}' < ./.github/uffizzi/docker-compose.uffizzi.yml > docker-compose.rendered.yml cat docker-compose.rendered.yml - name: Upload Rendered Compose File as Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: preview-spec + name: docker-compose path: docker-compose.rendered.yml retention-days: 2 - name: Upload PR Event as Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: preview-spec + name: event-path path: ${{ github.event_path }} retention-days: 2 @@ -75,8 +75,8 @@ jobs: steps: # If this PR is closing, we will not render a compose file nor pass it to the next workflow. - name: Upload PR Event as Artifact - uses: actions/upload-artifact@v3 + uses: actions/upload-artifact@v4 with: - name: preview-spec + name: event-path path: ${{ github.event_path }} retention-days: 2 diff --git a/.github/workflows/uffizzi-preview.yml b/.github/workflows/uffizzi-preview.yml index 7d7074f8b7..8e465d5f49 100644 --- a/.github/workflows/uffizzi-preview.yml +++ b/.github/workflows/uffizzi-preview.yml @@ -29,7 +29,7 @@ jobs: run_id: context.payload.workflow_run.id, }); let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => { - return artifact.name == "preview-spec" + return artifact.name == "docker-compose" || artifact.name == "event-path" })[0]; if (matchArtifact === undefined) { throw TypeError('Build Artifact not found!');