Pages:deploy stage is frequently failing

The pages:deploy stage has been failing frequently, though it occasionally succeeds with the same setup, as you can see from a few successful runs. Any help resolving this issue would be greatly appreciated.

stages:
- deploy

pages:
  stage: deploy
  image: alpine:latest
  script:
    - echo “Preparing GitLab Pages directory”
    - rm -rf public
    - mkdir -p public
    - cp -r swagger/\* public/
  artifacts:
    paths:
     - public
  only:
  - main
  - dev

  environment:
   name: swagger-docs
   url: gitlab.abc/${CI_PROJECT_PATH}

**project structure:**

.
├── .gitlab-ci.yml
├── swagger/
│ ├── index.html
│ ├── swagger.yaml
│ └── swagger-initializer.js