templates/.github/workflows/deploy-preview.yml
Mauricio Siu 1bb88e7c93 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.
2025-03-16 11:14:43 -06:00

54 lines
1.6 KiB
YAML

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