From 4fde69f674758085f57b5ecf4dff5ae2e82c060e Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 16 Mar 2025 11:02:43 -0600 Subject: [PATCH 01/10] feat: add GitHub Actions workflows for build and deploy preview - Introduced a new workflow for building the preview site and uploading build artifacts. - Added a deployment workflow to Cloudflare Pages triggered by the successful completion of the build workflow. - Configured Node.js and pnpm for dependency management and build processes. --- .github/workflows/build-preview.yml | 37 +++++++++++++++++++++++++++ .github/workflows/deploy-preview.yml | 38 ++++++++++++++++++++++++++++ 2 files changed, 75 insertions(+) create mode 100644 .github/workflows/build-preview.yml create mode 100644 .github/workflows/deploy-preview.yml diff --git a/.github/workflows/build-preview.yml b/.github/workflows/build-preview.yml new file mode 100644 index 0000000..89e2177 --- /dev/null +++ b/.github/workflows/build-preview.yml @@ -0,0 +1,37 @@ +name: Build Preview Deployment + +on: + pull_request: + types: [opened, synchronize] + +jobs: + build-preview: + runs-on: ubuntu-latest + name: Build Preview Site and Upload Build Artifact + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Install dependencies + working-directory: app + run: pnpm install + + - name: Build + working-directory: app + run: pnpm build + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: preview-build + path: app/dist \ No newline at end of file diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 0000000..436c572 --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,38 @@ +name: Upload Preview Deployment + +on: + workflow_run: + workflows: ['Build Preview Deployment'] + types: + - completed + +permissions: + actions: read + deployments: write + contents: read + pull-requests: write + +jobs: + deploy-preview: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + name: Deploy Preview to Cloudflare Pages + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 + id: preview-build-artifact + with: + name: preview-build + path: build + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Deploy to Cloudflare Pages + uses: AdrianGonz97/refined-cf-pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + githubToken: ${{ secrets.GITHUB_TOKEN }} + projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} + deploymentName: Preview + directory: ${{ steps.preview-build-artifact.outputs.download-path }} \ No newline at end of file From 4f25e703d009f70a16ac9840f988edc2e686e210 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 16 Mar 2025 11:04:58 -0600 Subject: [PATCH 02/10] Update README.md --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index b048cbf..242461c 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ This is the official repository for the Dokploy Open Source Templates. ### How to add a new template + 1. Fork the repository 2. Create a new branch 3. Add the template to the `blueprints` folder (docker-compose.yml, template.yml) From 5aa80f8c96d27618b73a5fd2d8cce60140a9a61d Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 16 Mar 2025 11:06:50 -0600 Subject: [PATCH 03/10] chore: update GitHub Actions workflow permissions and artifact retention - Added permissions for reading contents, actions, and writing pull requests. - Set artifact retention period to 1 day for the preview build. --- .github/workflows/build-preview.yml | 7 ++++++- .github/workflows/deploy-preview.yml | 18 +++++++++++------- 2 files changed, 17 insertions(+), 8 deletions(-) diff --git a/.github/workflows/build-preview.yml b/.github/workflows/build-preview.yml index 89e2177..fdc312a 100644 --- a/.github/workflows/build-preview.yml +++ b/.github/workflows/build-preview.yml @@ -8,6 +8,10 @@ jobs: build-preview: runs-on: ubuntu-latest name: Build Preview Site and Upload Build Artifact + permissions: + contents: read + actions: read + pull-requests: write steps: - name: Checkout uses: actions/checkout@v4 @@ -34,4 +38,5 @@ jobs: uses: actions/upload-artifact@v4 with: name: preview-build - path: app/dist \ No newline at end of file + path: app/dist + retention-days: 1 \ No newline at end of file diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 436c572..278a358 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -5,6 +5,8 @@ on: workflows: ['Build Preview Deployment'] types: - completed + branches-ignore: + - main permissions: actions: read @@ -15,17 +17,19 @@ permissions: jobs: deploy-preview: runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} + if: | + github.event.workflow_run.conclusion == 'success' && + github.event.workflow_run.event == 'pull_request' name: Deploy Preview to Cloudflare Pages steps: - - name: Download build artifact - uses: actions/download-artifact@v4 - id: preview-build-artifact + - name: Download artifact + uses: dawidd6/action-download-artifact@v3 with: + workflow: build-preview.yml name: preview-build path: build - github-token: ${{ secrets.GITHUB_TOKEN }} - run-id: ${{ github.event.workflow_run.id }} + run_id: ${{ github.event.workflow_run.id }} + if_no_artifact_found: error - name: Deploy to Cloudflare Pages uses: AdrianGonz97/refined-cf-pages-action@v1 @@ -35,4 +39,4 @@ jobs: githubToken: ${{ secrets.GITHUB_TOKEN }} projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} deploymentName: Preview - directory: ${{ steps.preview-build-artifact.outputs.download-path }} \ No newline at end of file + directory: build \ No newline at end of file From 2291e9a5d10419455b277c23496cfa210965151b Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 16 Mar 2025 11:10:02 -0600 Subject: [PATCH 04/10] chore: enhance GitHub Actions workflow with additional steps and permissions - Updated permissions to allow writing actions. - Added a step to list build output for verification. - Included a verification step to confirm artifact upload completion. --- .github/workflows/build-preview.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-preview.yml b/.github/workflows/build-preview.yml index fdc312a..7c8dc78 100644 --- a/.github/workflows/build-preview.yml +++ b/.github/workflows/build-preview.yml @@ -10,7 +10,7 @@ jobs: name: Build Preview Site and Upload Build Artifact permissions: contents: read - actions: read + actions: write pull-requests: write steps: - name: Checkout @@ -34,9 +34,15 @@ jobs: working-directory: app run: pnpm build + - name: List build output + run: ls -la app/dist + - name: Upload build artifact uses: actions/upload-artifact@v4 with: name: preview-build path: app/dist - retention-days: 1 \ No newline at end of file + retention-days: 1 + + - name: Verify artifact upload + run: echo "Artifact upload completed with ID ${{ steps.upload-artifact.step.outputs.artifact-id }}" \ No newline at end of file From 7e9dda562bcf8a310f9ac12cc3c3e38679f08cdb Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 16 Mar 2025 11:12:45 -0600 Subject: [PATCH 05/10] chore: update GitHub Actions workflows for improved artifact handling and debugging - Added an ID to the artifact upload step for better tracking. - Enhanced the verification step to include workflow and repository information. - Updated permissions to allow writing actions in the deploy workflow. - Added debug information to the deploy workflow for better visibility of event details. --- .github/workflows/build-preview.yml | 6 +++++- .github/workflows/deploy-preview.yml | 26 ++++++++++++++++++-------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build-preview.yml b/.github/workflows/build-preview.yml index 7c8dc78..3af44a1 100644 --- a/.github/workflows/build-preview.yml +++ b/.github/workflows/build-preview.yml @@ -38,6 +38,7 @@ jobs: run: ls -la app/dist - name: Upload build artifact + id: upload-artifact uses: actions/upload-artifact@v4 with: name: preview-build @@ -45,4 +46,7 @@ jobs: retention-days: 1 - name: Verify artifact upload - run: echo "Artifact upload completed with ID ${{ steps.upload-artifact.step.outputs.artifact-id }}" \ No newline at end of file + run: | + echo "Artifact upload completed" + echo "Workflow ID: ${{ github.run_id }}" + echo "Repository: ${{ github.repository }}" \ No newline at end of file diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 278a358..257fe95 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -5,11 +5,9 @@ on: workflows: ['Build Preview Deployment'] types: - completed - branches-ignore: - - main permissions: - actions: read + actions: write deployments: write contents: read pull-requests: write @@ -19,17 +17,29 @@ jobs: runs-on: ubuntu-latest if: | github.event.workflow_run.conclusion == 'success' && - github.event.workflow_run.event == 'pull_request' + github.event.workflow_run.head_repository.full_name == github.repository name: Deploy Preview to Cloudflare Pages steps: - - name: Download artifact + - name: Debug Info + env: + EVENT_JSON: ${{ toJSON(github.event) }} + run: | + echo "Workflow Run ID: ${{ github.event.workflow_run.id }}" + echo "Event Type: ${{ github.event.workflow_run.event }}" + echo "Repository: ${{ github.event.workflow_run.head_repository.full_name }}" + echo "Full Event: $EVENT_JSON" + + - name: Download artifacts uses: dawidd6/action-download-artifact@v3 with: - workflow: build-preview.yml + workflow: Build Preview Deployment + run_id: ${{ github.event.workflow_run.id }} name: preview-build path: build - run_id: ${{ github.event.workflow_run.id }} - if_no_artifact_found: error + search_artifacts: true + + - name: List files + run: ls -la build - name: Deploy to Cloudflare Pages uses: AdrianGonz97/refined-cf-pages-action@v1 From 1bb88e7c93960caa4f1f497873979edd3389bc70 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 16 Mar 2025 11:14:43 -0600 Subject: [PATCH 06/10] chore: refactor GitHub Actions workflow for clarity and structure - Updated workflow trigger to use a list format for better readability. - Separated the deploy preview job into distinct steps for improved organization. - Enhanced debug information to provide more detailed event context. - Updated artifact download action to the latest version for better performance. --- .github/workflows/deploy-preview.yml | 38 +++++++++++++++------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml index 257fe95..e55c990 100644 --- a/.github/workflows/deploy-preview.yml +++ b/.github/workflows/deploy-preview.yml @@ -2,7 +2,8 @@ name: Upload Preview Deployment on: workflow_run: - workflows: ['Build Preview Deployment'] + workflows: + - "Build Preview Deployment" types: - completed @@ -13,30 +14,31 @@ permissions: pull-requests: write jobs: - deploy-preview: + on-success: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Debug Event + run: | + echo "Event name: ${{ github.event_name }}" + echo "Workflow name: ${{ github.event.workflow.name }}" + echo "Workflow run id: ${{ github.event.workflow_run.id }}" + echo "Workflow run number: ${{ github.event.workflow_run.run_number }}" + echo "Workflow run conclusion: ${{ github.event.workflow_run.conclusion }}" + echo "Workflow run event: ${{ github.event.workflow_run.event }}" + + deploy-preview: + needs: on-success runs-on: ubuntu-latest - if: | - github.event.workflow_run.conclusion == 'success' && - github.event.workflow_run.head_repository.full_name == github.repository name: Deploy Preview to Cloudflare Pages steps: - - name: Debug Info - env: - EVENT_JSON: ${{ toJSON(github.event) }} - run: | - echo "Workflow Run ID: ${{ github.event.workflow_run.id }}" - echo "Event Type: ${{ github.event.workflow_run.event }}" - echo "Repository: ${{ github.event.workflow_run.head_repository.full_name }}" - echo "Full Event: $EVENT_JSON" - - name: Download artifacts - uses: dawidd6/action-download-artifact@v3 + uses: actions/download-artifact@v4 with: - workflow: Build Preview Deployment - run_id: ${{ github.event.workflow_run.id }} name: preview-build path: build - search_artifacts: true + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} - name: List files run: ls -la build From 6687f2723da2f0a7c268e6db01a4f4732e1f5b61 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 16 Mar 2025 11:15:34 -0600 Subject: [PATCH 07/10] chore: enhance build preview workflow with additional debug information - Updated workflow name to use quotes for consistency. - Added event name and event type to the debug output for improved context during deployments. --- .github/workflows/build-preview.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-preview.yml b/.github/workflows/build-preview.yml index 3af44a1..4aa110a 100644 --- a/.github/workflows/build-preview.yml +++ b/.github/workflows/build-preview.yml @@ -1,4 +1,4 @@ -name: Build Preview Deployment +name: "Build Preview Deployment" on: pull_request: @@ -49,4 +49,6 @@ jobs: run: | echo "Artifact upload completed" echo "Workflow ID: ${{ github.run_id }}" - echo "Repository: ${{ github.repository }}" \ No newline at end of file + echo "Repository: ${{ github.repository }}" + echo "Event name: ${{ github.event_name }}" + echo "Event type: ${{ github.event.action }}" \ No newline at end of file From 67798563406221270c84054b053cb87e1d0bc0c3 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 16 Mar 2025 11:17:03 -0600 Subject: [PATCH 08/10] chore: update build preview workflow to include deployment step - Renamed job to "Build and Deploy Preview" for clarity. - Added a deployment step to Cloudflare Pages with necessary configurations. - Updated permissions to include deployment rights. --- .github/workflows/build-preview.yml | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build-preview.yml b/.github/workflows/build-preview.yml index 4aa110a..537c958 100644 --- a/.github/workflows/build-preview.yml +++ b/.github/workflows/build-preview.yml @@ -1,17 +1,18 @@ -name: "Build Preview Deployment" +name: "Build and Deploy Preview" on: pull_request: types: [opened, synchronize] jobs: - build-preview: + build-and-deploy: runs-on: ubuntu-latest - name: Build Preview Site and Upload Build Artifact + name: Build and Deploy Preview permissions: contents: read actions: write pull-requests: write + deployments: write steps: - name: Checkout uses: actions/checkout@v4 @@ -37,6 +38,16 @@ jobs: - name: List build output run: ls -la app/dist + - name: Deploy to Cloudflare Pages + uses: AdrianGonz97/refined-cf-pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + githubToken: ${{ secrets.GITHUB_TOKEN }} + projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} + deploymentName: Preview + directory: app/dist + - name: Upload build artifact id: upload-artifact uses: actions/upload-artifact@v4 From d198755d25fee2ed1c6cd4ded8189a9a1a421fd7 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 16 Mar 2025 11:19:59 -0600 Subject: [PATCH 09/10] chore: remove deploy preview workflow from GitHub Actions - Deleted the deploy preview workflow file as it is no longer needed. - This change simplifies the workflow configuration and reduces maintenance overhead. --- .github/workflows/deploy-preview.yml | 54 ---------------------------- app/src/components/Search.tsx | 2 +- 2 files changed, 1 insertion(+), 55 deletions(-) delete mode 100644 .github/workflows/deploy-preview.yml diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml deleted file mode 100644 index e55c990..0000000 --- a/.github/workflows/deploy-preview.yml +++ /dev/null @@ -1,54 +0,0 @@ -name: Upload Preview Deployment - -on: - workflow_run: - workflows: - - "Build Preview Deployment" - types: - - completed - -permissions: - actions: write - deployments: write - contents: read - pull-requests: write - -jobs: - on-success: - runs-on: ubuntu-latest - if: ${{ github.event.workflow_run.conclusion == 'success' }} - steps: - - name: Debug Event - run: | - echo "Event name: ${{ github.event_name }}" - echo "Workflow name: ${{ github.event.workflow.name }}" - echo "Workflow run id: ${{ github.event.workflow_run.id }}" - echo "Workflow run number: ${{ github.event.workflow_run.run_number }}" - echo "Workflow run conclusion: ${{ github.event.workflow_run.conclusion }}" - echo "Workflow run event: ${{ github.event.workflow_run.event }}" - - deploy-preview: - needs: on-success - runs-on: ubuntu-latest - name: Deploy Preview to Cloudflare Pages - steps: - - name: Download artifacts - uses: actions/download-artifact@v4 - with: - name: preview-build - path: build - github-token: ${{ secrets.GITHUB_TOKEN }} - run-id: ${{ github.event.workflow_run.id }} - - - name: List files - run: ls -la build - - - name: Deploy to Cloudflare Pages - uses: AdrianGonz97/refined-cf-pages-action@v1 - with: - apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} - accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - githubToken: ${{ secrets.GITHUB_TOKEN }} - projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} - deploymentName: Preview - directory: build \ No newline at end of file diff --git a/app/src/components/Search.tsx b/app/src/components/Search.tsx index f95a7ea..a114c19 100644 --- a/app/src/components/Search.tsx +++ b/app/src/components/Search.tsx @@ -107,7 +107,7 @@ const Search = () => { From c0449a62bb1db1c37eb92a0714d3eeb607e60478 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Sun, 16 Mar 2025 11:30:44 -0600 Subject: [PATCH 10/10] chore: add production deployment workflow for Cloudflare Pages - Introduced a new GitHub Actions workflow for deploying the application to Cloudflare Pages upon pushes to the main branch. - Configured steps for Node.js setup, dependency installation, and build processes using pnpm. - Included necessary permissions and secrets for secure deployment. --- .../workflows/cloudflare-pages-production.yml | 47 +++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 .github/workflows/cloudflare-pages-production.yml diff --git a/.github/workflows/cloudflare-pages-production.yml b/.github/workflows/cloudflare-pages-production.yml new file mode 100644 index 0000000..d755e22 --- /dev/null +++ b/.github/workflows/cloudflare-pages-production.yml @@ -0,0 +1,47 @@ +name: Deploy to Cloudflare Pages (Production) + +on: + push: + branches: + - main + +jobs: + publish: + runs-on: ubuntu-latest + permissions: + contents: read + deployments: write + name: Publish to Cloudflare Pages + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Node.js + uses: actions/setup-node@v4 + with: + node-version: '20' + + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 8 + + - name: Install dependencies + working-directory: app + run: pnpm install + + - name: Build + working-directory: app + run: pnpm build + + - name: Publish to Cloudflare Pages + uses: AdrianGonz97/refined-cf-pages-action@v1 + with: + apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} + accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + githubToken: ${{ secrets.GITHUB_TOKEN }} + projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} + directory: app/dist + deploymentName: Production + branch: main + wranglerVersion: '3' \ No newline at end of file