From f7ef40e59652ea672a6dd457f6e5ab95333371ef Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Thu, 8 May 2025 12:35:25 +0200 Subject: [PATCH 01/16] Add deploy status --- .github/workflows/main.yaml | 29 +++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 40bcadb..92df11a 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -20,8 +20,6 @@ jobs: deployments: write name: Publish to Cloudflare Pages steps: - - - uses: actions/checkout@v3 - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 @@ -31,11 +29,34 @@ jobs: - run: npm ci - run: npm run build --if-present - - - name: Publish to Cloudflare Pages uses: cloudflare/wrangler-action@v3.10.0 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} command: pages deploy ./build --project-name=maculaweb + + - name: Add Pull Request Comment + if: github.event_name == 'pull_request' + uses: peter-evans/create-or-update-comment@v2 + with: + token: ${{ secrets.GITHUB_TOKEN }} + issue-number: ${{ github.event.pull_request.number }} + body: | + ## Deploy - Resultado + La aplicación se ha desplegado correctamente en Cloudflare Pages. + Puedes ver los detalles o acceder a la URL de deploy si está disponible. + + - name: Set Deploy Status + uses: actions/github-script@v6 + with: + script: | + await github.repos.createCommitStatus({ + owner: context.repo.owner, + repo: context.repo.repo, + sha: context.sha, + state: 'success', + context: 'Deploy', + description: 'Deployment succeeded', + target_url: 'https://' // Reemplaza con la URL de tu deploy, si aplicable. + }); \ No newline at end of file From 13729624aa8b8d2c2ec72e265f3c5f97bfb261f2 Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 15:30:56 +0200 Subject: [PATCH 02/16] Update main.yaml --- .github/workflows/main.yaml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 92df11a..9ca2eb8 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -50,13 +50,16 @@ jobs: - name: Set Deploy Status uses: actions/github-script@v6 with: + github-token: ${{ secrets.GITHUB_TOKEN }} script: | - await github.repos.createCommitStatus({ + // Use github.rest.repos.createCommitStatus instead of github.repos + const response = await github.rest.repos.createCommitStatus({ owner: context.repo.owner, repo: context.repo.repo, sha: context.sha, state: 'success', context: 'Deploy', description: 'Deployment succeeded', - target_url: 'https://' // Reemplaza con la URL de tu deploy, si aplicable. - }); \ No newline at end of file + target_url: 'https://premiosmacula.es' // Reemplaza con la URL de tu deploy, si aplicable. + }); + console.log(`Created commit status #${response.data.id}`); From 95bd041825c8a6bed9856f8a3174329c135cd97e Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 15:36:40 +0200 Subject: [PATCH 03/16] Update main.yaml --- .github/workflows/main.yaml | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 9ca2eb8..f2a28ac 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,5 +1,4 @@ -# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node -# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs +# This workflow installs deps, builds, deploys to Cloudflare Pages, comments on PRs and sets a commit status. name: Node.js deploy @@ -7,17 +6,17 @@ on: push: {} workflow_dispatch: +permissions: + contents: read + deployments: write + statuses: write # ← allow createCommitStatus + jobs: - deployCloudfare: runs-on: ubuntu-latest strategy: matrix: node-version: [20.6.1] - # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ - permissions: - contents: read - deployments: write name: Publish to Cloudflare Pages steps: - uses: actions/checkout@v3 @@ -26,6 +25,7 @@ jobs: with: node-version: ${{ matrix.node-version }} cache: 'npm' + - run: npm ci - run: npm run build --if-present @@ -43,7 +43,7 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.pull_request.number }} body: | - ## Deploy - Resultado + ## Deploy – Resultado La aplicación se ha desplegado correctamente en Cloudflare Pages. Puedes ver los detalles o acceder a la URL de deploy si está disponible. @@ -52,14 +52,14 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - // Use github.rest.repos.createCommitStatus instead of github.repos - const response = await github.rest.repos.createCommitStatus({ + // now works because GITHUB_TOKEN has 'statuses: write' + const res = await github.rest.repos.createCommitStatus({ owner: context.repo.owner, - repo: context.repo.repo, - sha: context.sha, + repo: context.repo.repo, + sha: context.sha, state: 'success', context: 'Deploy', description: 'Deployment succeeded', - target_url: 'https://premiosmacula.es' // Reemplaza con la URL de tu deploy, si aplicable. + target_url: 'https://premiosmacula.es' }); - console.log(`Created commit status #${response.data.id}`); + console.log(`✅ Created status id=${res.data.id}`); From 789673d9866aa20f7caeecf9ea1291540b34636a Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 15:47:30 +0200 Subject: [PATCH 04/16] Update main.yaml --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index f2a28ac..932c7c5 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -60,6 +60,6 @@ jobs: state: 'success', context: 'Deploy', description: 'Deployment succeeded', - target_url: 'https://premiosmacula.es' + target_url: '${{ steps.deploy.outputs.deployment-url }}' }); console.log(`✅ Created status id=${res.data.id}`); From ada1ea92dce1249a38d2fa6ea0cdb790ca56bf3b Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 15:56:26 +0200 Subject: [PATCH 05/16] Update main.yaml --- .github/workflows/main.yaml | 66 ++++++++++++++++++++----------------- 1 file changed, 36 insertions(+), 30 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 932c7c5..2834bdf 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,65 +1,71 @@ -# This workflow installs deps, builds, deploys to Cloudflare Pages, comments on PRs and sets a commit status. - -name: Node.js deploy +name: Deploy to Cloudflare Pages on: - push: {} - workflow_dispatch: + push: + branches: + - main + pull_request: permissions: contents: read - deployments: write - statuses: write # ← allow createCommitStatus + statuses: write # if you want to set commit statuses + pull-requests: write # if you want to comment on PRs jobs: - deployCloudfare: + build-and-deploy: runs-on: ubuntu-latest - strategy: - matrix: - node-version: [20.6.1] - name: Publish to Cloudflare Pages steps: - - uses: actions/checkout@v3 - - name: Use Node.js ${{ matrix.node-version }} + - name: Check out code + uses: actions/checkout@v3 + + - name: Use Node.js uses: actions/setup-node@v3 with: - node-version: ${{ matrix.node-version }} + node-version: '20' cache: 'npm' - - run: npm ci - - run: npm run build --if-present + - name: Install dependencies + run: npm ci - - name: Publish to Cloudflare Pages - uses: cloudflare/wrangler-action@v3.10.0 + - name: Build + run: npm run build --if-present + + - name: Deploy to Cloudflare Pages + id: deploy # <- give this step an ID + uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} command: pages deploy ./build --project-name=maculaweb - - name: Add Pull Request Comment + - name: Show deploy URL + run: | + echo "✓ Pages URL: ${{ steps.deploy.outputs.url }}" + + - name: Comment on PR with deploy URL if: github.event_name == 'pull_request' uses: peter-evans/create-or-update-comment@v2 with: token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.pull_request.number }} body: | - ## Deploy – Resultado - La aplicación se ha desplegado correctamente en Cloudflare Pages. - Puedes ver los detalles o acceder a la URL de deploy si está disponible. + 🚀 **Deployed Preview:** + ${{ steps.deploy.outputs.url }} - - name: Set Deploy Status + - name: Set GitHub commit status + if: github.event_name != 'pull_request' uses: actions/github-script@v6 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - // now works because GITHUB_TOKEN has 'statuses: write' - const res = await github.rest.repos.createCommitStatus({ + await github.rest.repos.createCommitStatus({ owner: context.repo.owner, - repo: context.repo.repo, - sha: context.sha, + repo: context.repo.repo, + sha: context.sha, state: 'success', context: 'Deploy', description: 'Deployment succeeded', - target_url: '${{ steps.deploy.outputs.deployment-url }}' + target_url: context.payload.pull_request + ? steps.deploy.outputs.url + : steps.deploy.outputs.url }); - console.log(`✅ Created status id=${res.data.id}`); From 212fd4b3fb1260e3c01ba69e22103422d2a58532 Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 16:01:30 +0200 Subject: [PATCH 06/16] Revert "Update main.yaml" This reverts commit ada1ea92dce1249a38d2fa6ea0cdb790ca56bf3b. --- .github/workflows/main.yaml | 66 +++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 36 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 2834bdf..932c7c5 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,71 +1,65 @@ -name: Deploy to Cloudflare Pages +# This workflow installs deps, builds, deploys to Cloudflare Pages, comments on PRs and sets a commit status. + +name: Node.js deploy on: - push: - branches: - - main - pull_request: + push: {} + workflow_dispatch: permissions: contents: read - statuses: write # if you want to set commit statuses - pull-requests: write # if you want to comment on PRs + deployments: write + statuses: write # ← allow createCommitStatus jobs: - build-and-deploy: + deployCloudfare: runs-on: ubuntu-latest + strategy: + matrix: + node-version: [20.6.1] + name: Publish to Cloudflare Pages steps: - - name: Check out code - uses: actions/checkout@v3 - - - name: Use Node.js + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} uses: actions/setup-node@v3 with: - node-version: '20' + node-version: ${{ matrix.node-version }} cache: 'npm' - - name: Install dependencies - run: npm ci + - run: npm ci + - run: npm run build --if-present - - name: Build - run: npm run build --if-present - - - name: Deploy to Cloudflare Pages - id: deploy # <- give this step an ID - uses: cloudflare/wrangler-action@v3 + - name: Publish to Cloudflare Pages + uses: cloudflare/wrangler-action@v3.10.0 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} command: pages deploy ./build --project-name=maculaweb - - name: Show deploy URL - run: | - echo "✓ Pages URL: ${{ steps.deploy.outputs.url }}" - - - name: Comment on PR with deploy URL + - name: Add Pull Request Comment if: github.event_name == 'pull_request' uses: peter-evans/create-or-update-comment@v2 with: token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.pull_request.number }} body: | - 🚀 **Deployed Preview:** - ${{ steps.deploy.outputs.url }} + ## Deploy – Resultado + La aplicación se ha desplegado correctamente en Cloudflare Pages. + Puedes ver los detalles o acceder a la URL de deploy si está disponible. - - name: Set GitHub commit status - if: github.event_name != 'pull_request' + - name: Set Deploy Status uses: actions/github-script@v6 with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - await github.rest.repos.createCommitStatus({ + // now works because GITHUB_TOKEN has 'statuses: write' + const res = await github.rest.repos.createCommitStatus({ owner: context.repo.owner, - repo: context.repo.repo, - sha: context.sha, + repo: context.repo.repo, + sha: context.sha, state: 'success', context: 'Deploy', description: 'Deployment succeeded', - target_url: context.payload.pull_request - ? steps.deploy.outputs.url - : steps.deploy.outputs.url + target_url: '${{ steps.deploy.outputs.deployment-url }}' }); + console.log(`✅ Created status id=${res.data.id}`); From a8b7283eaa7691e2e8c97bff95f886534730b775 Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 16:07:40 +0200 Subject: [PATCH 07/16] URL de estado de despliegue como una variable --- .github/workflows/main.yaml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 932c7c5..d3b43c1 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,5 +1,3 @@ -# This workflow installs deps, builds, deploys to Cloudflare Pages, comments on PRs and sets a commit status. - name: Node.js deploy on: @@ -30,6 +28,7 @@ jobs: - run: npm run build --if-present - name: Publish to Cloudflare Pages + id: deploy uses: cloudflare/wrangler-action@v3.10.0 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} @@ -43,9 +42,8 @@ jobs: token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.pull_request.number }} body: | - ## Deploy – Resultado - La aplicación se ha desplegado correctamente en Cloudflare Pages. - Puedes ver los detalles o acceder a la URL de deploy si está disponible. + 🚀 **Preview Publicada:** + ${{ steps.deploy.outputs.url }} - name: Set Deploy Status uses: actions/github-script@v6 @@ -60,6 +58,6 @@ jobs: state: 'success', context: 'Deploy', description: 'Deployment succeeded', - target_url: '${{ steps.deploy.outputs.deployment-url }}' + target_url: '${{ steps.deploy.outputs.url }}' }); console.log(`✅ Created status id=${res.data.id}`); From ff82bbc0023b296f9f9117a4c3206fc8d60f2fc6 Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 16:11:52 +0200 Subject: [PATCH 08/16] =?UTF-8?q?Corregir=20sintaxis=20en=20la=20condici?= =?UTF-8?q?=C3=B3n=20para=20agregar=20comentario=20en=20Pull=20Request?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index d3b43c1..ec2ffa4 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -36,7 +36,7 @@ jobs: command: pages deploy ./build --project-name=maculaweb - name: Add Pull Request Comment - if: github.event_name == 'pull_request' + if: ${{ github.event_name == 'pull_request' }} uses: peter-evans/create-or-update-comment@v2 with: token: ${{ secrets.GITHUB_TOKEN }} From 85d067f6c6e95e90ce1db7a5c831b87a54ca6cd0 Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 16:12:21 +0200 Subject: [PATCH 09/16] Corregir referencia a la URL de despliegue en el comentario de Pull Request y en el estado de despliegue --- .github/workflows/main.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index ec2ffa4..bb7aced 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -43,7 +43,7 @@ jobs: issue-number: ${{ github.event.pull_request.number }} body: | 🚀 **Preview Publicada:** - ${{ steps.deploy.outputs.url }} + ${{ steps.deploy.outputs.deployment-url }} - name: Set Deploy Status uses: actions/github-script@v6 @@ -58,6 +58,6 @@ jobs: state: 'success', context: 'Deploy', description: 'Deployment succeeded', - target_url: '${{ steps.deploy.outputs.url }}' + target_url: '${{ steps.deploy.outputs.deployment-url }}' }); console.log(`✅ Created status id=${res.data.id}`); From 2ab1262b6a6242ee82b3c456c8e01fe780f04945 Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 16:14:14 +0200 Subject: [PATCH 10/16] =?UTF-8?q?Revert=20"Corregir=20sintaxis=20en=20la?= =?UTF-8?q?=20condici=C3=B3n=20para=20agregar=20comentario=20en=20Pull=20R?= =?UTF-8?q?equest"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This reverts commit ff82bbc0023b296f9f9117a4c3206fc8d60f2fc6. --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index bb7aced..254817c 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -36,7 +36,7 @@ jobs: command: pages deploy ./build --project-name=maculaweb - name: Add Pull Request Comment - if: ${{ github.event_name == 'pull_request' }} + if: github.event_name == 'pull_request' uses: peter-evans/create-or-update-comment@v2 with: token: ${{ secrets.GITHUB_TOKEN }} From 3d9d42792b787551e40e4e4cbe44f0113b6c0789 Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 16:16:21 +0200 Subject: [PATCH 11/16] Corregir referencia a la URL de despliegue en el comentario de Pull Request y en el estado de despliegue --- .github/workflows/main.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 254817c..1ed1e97 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -43,7 +43,7 @@ jobs: issue-number: ${{ github.event.pull_request.number }} body: | 🚀 **Preview Publicada:** - ${{ steps.deploy.outputs.deployment-url }} + ${{ steps.deploy.outputs.deployment-alias-url }} - name: Set Deploy Status uses: actions/github-script@v6 @@ -58,6 +58,6 @@ jobs: state: 'success', context: 'Deploy', description: 'Deployment succeeded', - target_url: '${{ steps.deploy.outputs.deployment-url }}' + target_url: '${{ steps.deploy.outputs.deployment-alias-url }}' }); console.log(`✅ Created status id=${res.data.id}`); From b517157542e9f9e1dc487083973e3aa89bd1e2de Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 16:26:43 +0200 Subject: [PATCH 12/16] =?UTF-8?q?Actualizar=20acci=C3=B3n=20de=20Cloudflar?= =?UTF-8?q?e=20Wrangler=20a=20la=20=C3=BAltima=20versi=C3=B3n?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 1ed1e97..4cd47a5 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -29,7 +29,7 @@ jobs: - name: Publish to Cloudflare Pages id: deploy - uses: cloudflare/wrangler-action@v3.10.0 + uses: cloudflare/wrangler-action@v3 with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} From 875883117568f28b28870e7ef7c0a424da09ea05 Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 16:35:28 +0200 Subject: [PATCH 13/16] =?UTF-8?q?Actualizar=20configuraci=C3=B3n=20del=20f?= =?UTF-8?q?lujo=20de=20trabajo=20de=20despliegue=20en=20Cloudflare:=20ajus?= =?UTF-8?q?tar=20ramas=20de=20push,=20actualizar=20versi=C3=B3n=20de=20acc?= =?UTF-8?q?i=C3=B3n=20para=20comentarios=20y=20mejorar=20el=20manejo=20del?= =?UTF-8?q?=20estado=20de=20despliegue.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yaml | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 4cd47a5..6b13faf 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -1,13 +1,18 @@ name: Node.js deploy on: - push: {} + push: + branches: + - main + pull_request: + types: [opened, synchronize, reopened] workflow_dispatch: permissions: contents: read deployments: write - statuses: write # ← allow createCommitStatus + statuses: write + pull-requests: write jobs: deployCloudfare: @@ -33,16 +38,16 @@ jobs: with: apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} - command: pages deploy ./build --project-name=maculaweb + command: pages deploy ./build --project-name=maculaweb --branch=${{ github.head_ref || github.ref_name }} - name: Add Pull Request Comment if: github.event_name == 'pull_request' - uses: peter-evans/create-or-update-comment@v2 + uses: peter-evans/create-or-update-comment@v4 with: token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.pull_request.number }} body: | - 🚀 **Preview Publicada:** + 🚀 **Preview Publicada:** ${{ steps.deploy.outputs.deployment-alias-url }} - name: Set Deploy Status @@ -50,14 +55,17 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - // now works because GITHUB_TOKEN has 'statuses: write' - const res = await github.rest.repos.createCommitStatus({ + const conclusion = '${{ job.status }}'; + const pr_alias_url = '${{ steps.deploy.outputs.alias }}'; + const direct_deploy_url = '${{ steps.deploy.outputs.url }}'; + + await github.rest.repos.createCommitStatus({ owner: context.repo.owner, - repo: context.repo.repo, - sha: context.sha, - state: 'success', - context: 'Deploy', - description: 'Deployment succeeded', - target_url: '${{ steps.deploy.outputs.deployment-alias-url }}' + repo: context.repo.repo, + sha: context.sha, + state: conclusion, + context: 'Deploy to Cloudflare Pages', + description: conclusion === 'success' ? 'Deployment Succeeded!' : 'Deployment Failed or Cancelled', + target_url: final_target_url }); - console.log(`✅ Created status id=${res.data.id}`); + console.log(`✅ Created commit status: ${conclusion} for ${context.sha} with target URL: ${final_target_url}`); \ No newline at end of file From f2f2bd6806f457fb3c8e5acc8041875dbda16bec Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 16:39:12 +0200 Subject: [PATCH 14/16] =?UTF-8?q?Simplificar=20la=20creaci=C3=B3n=20del=20?= =?UTF-8?q?estado=20de=20commit=20en=20el=20flujo=20de=20trabajo=20de=20de?= =?UTF-8?q?spliegue:=20eliminar=20variables=20innecesarias=20y=20mejorar?= =?UTF-8?q?=20la=20legibilidad=20del=20c=C3=B3digo.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yaml | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 6b13faf..b615baf 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -55,17 +55,14 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} script: | - const conclusion = '${{ job.status }}'; - const pr_alias_url = '${{ steps.deploy.outputs.alias }}'; - const direct_deploy_url = '${{ steps.deploy.outputs.url }}'; - - await github.rest.repos.createCommitStatus({ + // now works because GITHUB_TOKEN has 'statuses: write' + const res = await github.rest.repos.createCommitStatus({ owner: context.repo.owner, - repo: context.repo.repo, - sha: context.sha, - state: conclusion, - context: 'Deploy to Cloudflare Pages', - description: conclusion === 'success' ? 'Deployment Succeeded!' : 'Deployment Failed or Cancelled', - target_url: final_target_url + repo: context.repo.repo, + sha: context.sha, + state: 'success', + context: 'Deploy', + description: 'Deployment correcto', + target_url: '${{ steps.deploy.outputs.deployment-alias-url }}' }); - console.log(`✅ Created commit status: ${conclusion} for ${context.sha} with target URL: ${final_target_url}`); \ No newline at end of file + console.log(`✅ Created status id=${res.data.id}`); \ No newline at end of file From aab050766520bfb8c0067adae7cb58b317f9d6b1 Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 16:47:18 +0200 Subject: [PATCH 15/16] Actualizar workflow para reemplazar comentario de preview en PRs en vez de crear uno nuevo --- .github/workflows/main.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b615baf..a4a1012 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -46,6 +46,8 @@ jobs: with: token: ${{ secrets.GITHUB_TOKEN }} issue-number: ${{ github.event.pull_request.number }} + edit-mode: replace + body-includes: "🚀 **Preview Publicada:**" body: | 🚀 **Preview Publicada:** ${{ steps.deploy.outputs.deployment-alias-url }} From cedb01e3ce02bbcae29023547c19410c4d982508 Mon Sep 17 00:00:00 2001 From: PGSCOM <69808296+PGSCOM@users.noreply.github.com> Date: Sat, 10 May 2025 16:53:46 +0200 Subject: [PATCH 16/16] =?UTF-8?q?Agregar=20b=C3=BAsqueda=20y=20actualizaci?= =?UTF-8?q?=C3=B3n=20de=20comentario=20de=20vista=20previa=20en=20Pull=20R?= =?UTF-8?q?equests?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/main.yaml | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index a4a1012..6ec4438 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -40,17 +40,25 @@ jobs: accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} command: pages deploy ./build --project-name=maculaweb --branch=${{ github.head_ref || github.ref_name }} + - name: Find Preview Comment + if: github.event_name == 'pull_request' + uses: peter-evans/find-comment@v3 + id: fc + with: + issue-number: ${{ github.event.pull_request.number }} + comment-author: 'github-actions[bot]' + body-includes: "🚀 **Preview Publicada:**" + - name: Add Pull Request Comment if: github.event_name == 'pull_request' uses: peter-evans/create-or-update-comment@v4 with: - token: ${{ secrets.GITHUB_TOKEN }} + comment-id: ${{ steps.fc.outputs.comment-id }} issue-number: ${{ github.event.pull_request.number }} - edit-mode: replace - body-includes: "🚀 **Preview Publicada:**" body: | 🚀 **Preview Publicada:** ${{ steps.deploy.outputs.deployment-alias-url }} + edit-mode: replace - name: Set Deploy Status uses: actions/github-script@v6