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.
This commit is contained in:
Mauricio Siu
2025-03-16 11:06:50 -06:00
parent 4f25e703d0
commit 5aa80f8c96
2 changed files with 17 additions and 8 deletions

View File

@@ -8,6 +8,10 @@ jobs:
build-preview: build-preview:
runs-on: ubuntu-latest runs-on: ubuntu-latest
name: Build Preview Site and Upload Build Artifact name: Build Preview Site and Upload Build Artifact
permissions:
contents: read
actions: read
pull-requests: write
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
@@ -34,4 +38,5 @@ jobs:
uses: actions/upload-artifact@v4 uses: actions/upload-artifact@v4
with: with:
name: preview-build name: preview-build
path: app/dist path: app/dist
retention-days: 1

View File

@@ -5,6 +5,8 @@ on:
workflows: ['Build Preview Deployment'] workflows: ['Build Preview Deployment']
types: types:
- completed - completed
branches-ignore:
- main
permissions: permissions:
actions: read actions: read
@@ -15,17 +17,19 @@ permissions:
jobs: jobs:
deploy-preview: deploy-preview:
runs-on: ubuntu-latest 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 name: Deploy Preview to Cloudflare Pages
steps: steps:
- name: Download build artifact - name: Download artifact
uses: actions/download-artifact@v4 uses: dawidd6/action-download-artifact@v3
id: preview-build-artifact
with: with:
workflow: build-preview.yml
name: preview-build name: preview-build
path: 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 - name: Deploy to Cloudflare Pages
uses: AdrianGonz97/refined-cf-pages-action@v1 uses: AdrianGonz97/refined-cf-pages-action@v1
@@ -35,4 +39,4 @@ jobs:
githubToken: ${{ secrets.GITHUB_TOKEN }} githubToken: ${{ secrets.GITHUB_TOKEN }}
projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} projectName: ${{ secrets.CLOUDFLARE_PROJECT_NAME }}
deploymentName: Preview deploymentName: Preview
directory: ${{ steps.preview-build-artifact.outputs.download-path }} directory: build