mehrancodes / laravel-harbor

a cli tool to Quickly create on-demand preview environment for your app on Laravel Forge.
https://www.laravel-harbor.com
MIT License
75 stars 7 forks source link

Setup with Gitlab advice #99

Open samshupac opened 6 months ago

samshupac commented 6 months ago

For anyone else searching for how to setup Harbor on Gitlab CI this should be useful. (Based on a pipeline initiated from the merge request context and having Gitlab setup as a Git provider in Forge)

harbor-provision-staging-site:
  stage: deploy
  variables:
    FORGE_TOKEN: XXXXX
    FORGE_SERVER: XXXXX
    FORGE_GIT_PROVIDER: gitlab # <-- This is critical and not documented currently
    FORGE_GIT_REPOSITORY: $CI_MERGE_REQUEST_PROJECT_PATH
    FORGE_GIT_BRANCH: $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
    FORGE_DOMAIN: XXXXX
    FORGE_DEPLOY_SCRIPT: "git pull origin $$FORGE_SITE_BRANCH;"
  dependencies: []
  rules:
    - if: $CI_MERGE_REQUEST_PROJECT_PATH != '' # ensures the job only runs in merge request context
      when: manual
  image: kirschbaumdevelopment/laravel-test-runner:8.1
  script:
    # Install Harbor via Composer
    - composer global require mehrancodes/laravel-harbor -q
    # Start Provisioning
    - harbor provision

Note: the escaped variables with double dollar symbols in the the FORGE_DEPLOY_SCRIPT

mehrancodes commented 6 months ago

Thanks a bunch for giving it a go with GitLab! I'll make sure to include FORGE_GIT_PROVIDER in the docs soon.

Having this example documented would be super helpful for folks looking to use Harbor with GitLab. I take care of it soon. Appreciate your help!