GitLab and Pantheon Project: Deployment Error

Problem to solve

Describe your question in as much detail as possible:

Steps to reproduce

  • Create a GitLab project

  • Create a Pantheon project

  • Add public SSH key on GitLab and Pantheon

  • Clone Pantheon project

  • Change the git remote origin to point to GitLab, instead of Pantheon

  • Add git remote set-url origin [GitLab repository URL]

  • Run git push origin master --force

  • Create .gitlab-ci.yml file

  • Add the following code on gitlab-ci.yml file

before_script:
  # See https://docs.gitlab.com/ee/ci/ssh_keys/
  - eval $(ssh-agent -s)
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
  - mkdir -p $HOME/.ssh && echo "StrictHostKeyChecking no" >> "$HOME/.ssh/config"
  - git config --global user.email "$GITLAB_USER_EMAIL"
  - git config --global user.name "Gitlab CI"
  • Add SSH_PRIVATE_KEY environment variable on GitLab Settings > CI/CD → Variables
    -----BEGIN OPENSSH PRIVATE KEY-----
    ssh private key
    -----END OPENSSH PRIVATE KEY-----
    The key works with additional line after -----END OPENSSH PRIVATE KEY-----

  • Add PANTHEON_SITE environment variable, in my case it is sergey-drupal-2024
    Screenshot from 2024-06-15 13-04-40

  • Add GIT_PANTHEON_URL. ssh://codeserver.dev.MY_ID.drush.in:2222/~/repository.git

  • Change the code of gitlab-ci.yml file

stages:
- deploy

before_script:
  # See https://docs.gitlab.com/ee/ci/ssh_keys/
  - eval $(ssh-agent -s)
  - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add - > /dev/null
  - mkdir -p $HOME/.ssh && echo "StrictHostKeyChecking no" >> "$HOME/.ssh/config"
  - git config --global user.email "$GITLAB_USER_EMAIL"
  - git config --global user.name "Gitlab CI"

deploy:dev:
  stage: deploy
  environment:
    name: dev
    url: https://dev-$PANTHEON_SITE.pantheonsite.io/
  script:
    - git remote add pantheon $PANTHEON_GIT_URL
    - git push pantheon master --force
  only:
    - master
  • git add ., git commit -m “Commit text”, git push