fixes gitlab ci
This commit is contained in:
@ -1,22 +1,54 @@
|
||||
# Default image for jobs - contains Hugo Extended
|
||||
image: klakegg/hugo:ext
|
||||
|
||||
variables:
|
||||
HUGO_ENV: production
|
||||
# Define GIT_STRATEGY=none for the deploy job if you don't need the repo fetched again
|
||||
# GIT_STRATEGY: none # Uncomment if deploy job doesn't need repo source
|
||||
|
||||
deploy:
|
||||
stage: deploy
|
||||
image: node:18
|
||||
only:
|
||||
stages:
|
||||
- build # Added build stage
|
||||
- deploy
|
||||
before_script:
|
||||
- npm install -g cloudron-surfer
|
||||
|
||||
# Job to build the Hugo site
|
||||
build_site:
|
||||
stage: build
|
||||
# This job uses the default image (klakegg/hugo:ext)
|
||||
script:
|
||||
- echo "Starting Hugo build..."
|
||||
- hugo version
|
||||
- hugo --minify --gc --cleanDestinationDir
|
||||
- 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:
|
||||
- deploy # Example: Run only on the main branch
|
||||
|
||||
# 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'
|
||||
before_script:
|
||||
- echo "Installing cloudron-surfer..."
|
||||
- npm install -g cloudron-surfer
|
||||
script:
|
||||
- echo "Deploying to: $SURFER_SERVER"
|
||||
- tar -czf deploy.tar.gz -C public .
|
||||
- surfer put --token $SURFER_TOKEN --server $SURFER_SERVER deploy.tar.gz /tmp/deploy.tar.gz
|
||||
- surfer exec --token $SURFER_TOKEN --server $SURFER_SERVER "tar -xzf /tmp/deploy.tar.gz -C / && rm /tmp/deploy.tar.gz"
|
||||
# Verify artifact downloaded correctly
|
||||
- echo "Contents of downloaded artifact:"
|
||||
- ls -la public/
|
||||
- echo "Uploading files to server"
|
||||
- surfer put --token $SURFER_TOKEN --server $SURFER_SERVER public/* /
|
||||
- echo "Deployment completed successfully"
|
||||
# Define when this job runs (e.g., only on the main branch after build)
|
||||
# Adjust 'only' or 'rules' as needed for your workflow
|
||||
only:
|
||||
- deploy # Example: Run only on the main branch
|
||||
|
||||
|
Reference in New Issue
Block a user