cloudflare / pages-action

MIT License
440 stars 91 forks source link

Workflow fails with `EACCES: permission denied, open '/home/runner/work/../...` #89

Open KamaniBhavin opened 1 year ago

KamaniBhavin commented 1 year ago

I have a GitHub workflow that utilizes two actions: cloudflare/wrangler-action@2.0.0 and cloudflare/pages-action@v1. However, these actions are not functioning as expected.

name: Deploy 

on:
  push:
    branches:
      - main

jobs:
  deploy:
    runs-on: ubuntu-latest
    permissions:
      contents: read
      deployments: write
    name: Deploy SIYA
    env:
      SENTRY_DSN: ${{ secrets.SENTRY_DSN }}
      DATABASE_URL: ${{ secrets.DATABASE_URL }}

    steps:
      - uses: actions/checkout@v2

      - name: Restore cache
        id: restore-cache
        uses: actions/cache@v2
        with:
          path: node_modules
          key: ${{ runner.os }}-restore-cache-${{ hashFiles('package-lock.json') }}
          restore-keys: |
            ${{ runner.os }}-restore-cache-

      - name: Install dependencies
        id: install-dependencies
        if: steps.restore-cache.outputs.cache-hit != 'true'
        run: |
          npm run setup

      - name: Deploy Slack bot
        id: deploy-slack-bot
        uses: cloudflare/wrangler-action@2.0.0
        with:
          wranglerVersion: '3.0.0'
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          workingDirectory: packages/slack-bot
          command: deploy
          secrets: |
            DATABASE_URL
            SLACK_CLIENT_SECRET
            SLACK_SIGNING_SECRET
            SENTRY_DSN
        env:
          SLACK_CLIENT_SECRET: ${{ secrets.SLACK_CLIENT_SECRET }}
          SLACK_SIGNING_SECRET: ${{ secrets.SLACK_SIGNING_SECRET }}

      - name: Cache Siya site
        id: cache-siya-site
        uses: actions/cache@v2
        with:
          path: packages/siya-site/build
          key: ${{ runner.os }}-cache-siya-site-${{ hashFiles('packages/siya-site/src/**') }}-${{ hashFiles('packages/siya-site/public/**') }}
          restore-keys: |
            ${{ runner.os }}-cache-siya-site-

      - name: Build Siya site
        id: build-siya-site
        if: steps.cache-siya-site.outputs.cache-hit != 'true'
        run: |
          cd packages/siya-site
          npm run build
          chmod 777 /home/runner/work/siya/siya/node_modules/

      - name: Deploy Siya site
        id: deploy-site
        uses: cloudflare/pages-action@v1
        with: 
          wranglerVersion: '3'
          projectName: siya-site
          branch: main
          directory: packages/siya-site/build
          apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
          accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
          githubToken: ${{ secrets.GITHUB_TOKEN }}     

The workflow above encounters an error message stating "EACCES: permission denied, open '/home/runner/work/siya/siya/node_modules/.cache/wrangler/pages.json'."

Here is the error message screenshot:

Screenshot 2023-06-01 at 12 10 05 PM

An attempt was made to resolve the issue by using the command chmod -R 777 /home/runner/work/siya/siya/node_modules/.cache, but it resulted in an error message stating "operation not allowed."

Here is the screenshot of the error message:

Screenshot 2023-06-01 at 12 19 38 PM

Although it deploy the static asset to pages, but fails the workflow. If someone could assist in understanding the problem and provide a fix or workaround, it would be greatly appreciated.