Skip to content
Snippets Groups Projects
Commit 3735871a authored by Moritz Stückler's avatar Moritz Stückler :cowboy:
Browse files

feat: add ci pipeline

parent 47418c57
No related branches found
No related tags found
No related merge requests found
Pipeline #5950 passed
image: node:alpine
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_COMMIT_BRANCH == "main"
build:
stage: build
variables:
GIT_STRATEGY: fetch
script:
# 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
url: $TARGET_HOST/$CI_PROJECT_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 "$SSH_KNOWN_HOSTS" >> ~/.ssh/known_hosts
- echo "Deploying for branch $CI_COMMIT_REF_SLUG – will be available at 🌎 $TARGET_HOST/$CI_PROJECT_NAME/$CI_COMMIT_REF_SLUG"
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; mirror --reverse --delete ./dist/ $SFTP_FOLDER/$CI_PROJECT_NAME/$CI_COMMIT_REF_SLUG/; bye"
environment:
name: $CI_COMMIT_REF_SLUG
url: $TARGET_HOST/$CI_PROJECT_NAME/$CI_COMMIT_REF_SLUG
on_stop: delete
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_PROJECT_NAME/$CI_COMMIT_REF_SLUG/; bye"
when: manual
environment:
name: $CI_COMMIT_REF_SLUG
action: stop
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment