2021-11-14 15:45:38 +03:00
|
|
|
# The base image is Alpine Linux, because it's small and awesome
|
2021-11-14 10:43:46 +00:00
|
|
|
image: alpine:latest
|
|
|
|
|
|
|
|
stages: # List of stages for jobs, and their order of execution
|
|
|
|
- build
|
|
|
|
- test
|
|
|
|
- deploy
|
|
|
|
|
|
|
|
build-job: # This job runs in the build stage, which runs first.
|
|
|
|
stage: build
|
2021-11-14 14:58:25 +03:00
|
|
|
before_script:
|
|
|
|
- echo "Installing the dependencies..."
|
2022-01-18 20:18:05 +03:00
|
|
|
- apk add discount make bash perl gcc
|
2021-11-14 10:43:46 +00:00
|
|
|
script:
|
2021-11-14 13:52:33 +03:00
|
|
|
- make THEME=discount-theme
|
2021-11-14 10:43:46 +00:00
|
|
|
artifacts:
|
|
|
|
paths:
|
2022-03-16 21:35:44 +03:00
|
|
|
- "public"
|
2021-11-14 10:43:46 +00:00
|
|
|
|
|
|
|
unit-test-job: # This job runs in the test stage.
|
|
|
|
stage: test # It only starts when the job in the build stage completes successfully.
|
|
|
|
script:
|
2022-03-16 21:35:44 +03:00
|
|
|
- test $(stat -c %s public/index.html) -gt 0 #test that the index file exists
|
2021-11-14 10:43:46 +00:00
|
|
|
|
|
|
|
deploy-job: # This job runs in the deploy stage.
|
|
|
|
stage: deploy # It only runs when *both* jobs in the test stage complete successfully.
|
2021-11-29 12:13:13 +03:00
|
|
|
only:
|
|
|
|
- main #Do not run the deploy pipeline on merge requests
|
2021-11-14 14:58:25 +03:00
|
|
|
before_script:
|
2021-11-29 12:13:13 +03:00
|
|
|
- if [ -z "$DEPLOY_PRIVATE_KEY" ]; then echo "Can't deploy without a private key."; exit 1; fi
|
2021-11-14 14:58:25 +03:00
|
|
|
- echo "Installing the dependencies..."
|
2022-03-16 20:04:40 +03:00
|
|
|
- apk add bash rsync openssh-client curl jq
|
2021-11-14 17:30:18 +03:00
|
|
|
- mkdir -m 700 -p ~/.ssh
|
|
|
|
- echo "$DEPLOY_PRIVATE_KEY" > ~/.ssh/id_rsa
|
|
|
|
- chmod 600 ~/.ssh/id_rsa
|
2022-03-16 19:50:58 +03:00
|
|
|
- curl https://gitlab.com/dev_urandom/neocities-uploader/-/raw/main/upload.sh?inline=false > upload.sh
|
|
|
|
- chmod +x upload.sh
|
2021-11-14 10:43:46 +00:00
|
|
|
script:
|
2022-03-16 21:35:44 +03:00
|
|
|
- rsync -e "ssh -o StrictHostKeyChecking=no" -ciIlprz public/ deploy@devurandom.xyz:~/out/
|
2022-03-16 19:50:58 +03:00
|
|
|
- ./upload.sh
|