Newer
Older
variables:
TEMPLATE_DOWNLOAD_URL: https://gitlab.fabcity.hamburg/fcos-suite/fcos-suite-astro/-/archive/main/fcos-suite-astro-main.zip
TEMPLATE_FILENAME: template.zip
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_COMMIT_BRANCH == "main"
build:
stage: build
before_script:
# Download ZIP file from the Astro repo (faster than Git cloning)
- curl $TEMPLATE_DOWNLOAD_URL -o $TEMPLATE_FILENAME
- unzip -o $TEMPLATE_FILENAME
# Copy all files from the template repo, except Content Markdown files (already in working dir)
- rsync -va --exclude="src/pages/**/*.md" --exclude="src/pages/**/*.mdx" --exclude="src/content/**/*.md" --exclude="src/content/**/*.mdx" --exclude="src/content/**/*.yaml" --exclude="src/content/**/*.yml" --exclude="public" --exclude ".git" fcos-suite-astro-main/ .
- rm -rf fcos-suite-astro-main
# Replacing the whole Astro config is a temporary workaround b/c Astro
# currently doesn't support env variables inside of the config file.
# See: https://github.com/withastro/astro/issues/3897
- echo "$ASTRO_CONFIG" > astro.config.mjs
- cat astro.config.mjs
- npm ci
- npm run build
artifacts:
name: "$CI_COMMIT_REF_SLUG"
expire_in: 1 day
paths:
- dist
environment:
name: $CI_COMMIT_REF_SLUG
deploy:
stage: deploy
variables:
GIT_STRATEGY: none
before_script:
- apk update
- apk add --no-cache lftp openssh
- mkdir -p ~/.ssh
- echo "$HTACCESS" >> dist/.htaccess
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- echo "Deploying for branch $CI_COMMIT_REF_SLUG – will be available at 🌎 $SITE_URL"
- lftp -e "set ftp:list-options -a; set net:timeout 5; set net:max-retries 3; set net:reconnect-interval-base 5; open sftp://$SFTP_HOST; user $SFTP_USER $SFTP_PASSWORD; mirror --exclude .well-known/ --reverse --delete ./dist/ $SFTP_FOLDER/$CI_COMMIT_REF_SLUG/; bye"
delete:
stage: deploy
variables:
GIT_STRATEGY: none
before_script:
- apk update
- apk add --no-cache lftp openssh
- mkdir -p ~/.ssh
- echo "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
script:
- lftp -e "set ftp:list-options -a; set net:timeout 5; set net:max-retries 3; set net:reconnect-interval-base 5; open sftp://$SFTP_HOST; user $SFTP_USER $SFTP_PASSWORD; rm -r $SFTP_FOLDER/$CI_COMMIT_REF_SLUG/; bye"
when: manual
environment:
name: $CI_COMMIT_REF_SLUG
action: stop