# Default image for jobs - contains Hugo Extended image: name: hugomods/hugo:node entrypoint: [""] variables: HUGO_ENV: production # Tells GitLab Runner to initialize and update submodules recursively GIT_SUBMODULE_STRATEGY: recursive # TODO: the Surfer server base url (ex: "https://www.example.com/") SURFER_SERVER: "" stages: - build # Added build stage - deploy # Job to build the Hugo site build_site: stage: build before_script: - echo "installing NPM packages" - npm install script: - echo "Starting Hugo build..." - hugo version - hugo --minify --gc --cleanDestinationDir # Build the site - echo "Build completed. Public directory contents:" - ls -la public/ artifacts: paths: - public/ # Pass the 'public' directory to the next stage expire_in: 1 hour # Optional: Set artifact expiry # Define when this job runs (e.g., only on the main branch) # Adjust 'only' or 'rules' as needed for your workflow only: - publish # the script will only run on the branch 'publish' # Job to deploy the built site using cloudron-surfer deploy_site: stage: deploy image: node:18 # Use Node.js image for cloudron-surfer needs: # Ensure 'build_site' job completes successfully first - job: build_site artifacts: true # Download artifacts from 'build_site' variables: GIT_STRATEGY: none # Optimization: Don't fetch repo source code for deploy job before_script: - echo "Installing cloudron-surfer..." - npm install -g cloudron-surfer script: - 'echo "Deploying to: $SURFER_SERVER"' # Verify artifact downloaded correctly - echo "Contents of downloaded artifact:" - ls -la public/ # Artifacts are extracted to the root of the job workspace - echo "Uploading files to server using surfer put..." # TODO: Makesure to add a $SURFER_TOKEN to GitLab under the repo settings > CI/CD > Variables - >- surfer put --token $SURFER_TOKEN --server $SURFER_SERVER public/* / - echo "Deployment completed successfully" only: - publish # Example: Run only on the main branch