Cloudflare Pages Deployment GitlabCI

Hi Community,

I have small web application which I want to deploy on Cloudflare Pages. The repository is stored on my private GitLab instance, that means I can’t use the default GitLab integration.

My attempt is to write a custom pipeline step with GitLab CI to upload the static files. Currently, the step looks like this:

deploy:
  dependencies:
    - build
  image: node:16-alpine
  variables:
    CLOUDFLARE_ACCOUNT_ID: $CLOUDFLARE_ACCOUNT_ID
    CLOUDFLARE_API_TOKEN: $CLOUDFLARE_API_TOKEN
    CLOUDFLARE_PROJECT_NAME: $CLOUDFLARE_PROJECT_NAME
  before_script:
    yarn global add wrangler
  script:
    - | wrangler pages publish public 
        --project-name=${CLOUDFLARE_PROJECT_NAME} 
        --branch=${CI_COMMIT_BRANCH} 
        --commit-hash=${CI_COMMIT_SHA} 
        --commit-message=${CI_COMMIT_MESSAGE}

The variables are set in the repository CI configuration.

My problem is that the pipeline fails with the given error.

$ wrangler pages publish public --project-name=${CLOUDFLARE_PROJECT_NAME} --branch=${CI_COMMIT_BRANCH} --commit-hash=${CI_COMMIT_SHA} --commit-message=${CI_COMMIT_MESSAGE}
✘ [ERROR] Unknown arguments: add, deployment

Has anyone experienced a similar issue and knows how to solve it?