1
0
mirror of https://gitlab.com/Anson-Projects/zine.git synced 2025-06-15 13:16:39 +00:00
zine/.gitlab-ci.yml
2024-12-10 21:47:08 -07:00

86 lines
1.7 KiB
YAML

stages:
- build
- lint
- test
- build_site
- deploy
- notify
variables:
CARGO_HOME: "$CI_PROJECT_DIR/cargo"
DEFAULT_PIPELINE_NAME: "$CI_COMMIT_BRANCH - $CI_COMMIT_MESSAGE"
SCHEDULED_PIPELINE_NAME: "Daily scheduled build pipeline"
cache:
paths:
- target/
- cargo/
build:
image: rust:latest
stage: build
script:
- cargo build
lint:
image: rust:latest
stage: lint
script:
- rustup component add clippy
- cargo clippy --all-targets -- -D warnings
test:
image: rust:latest
stage: test
script:
- cargo test --verbose
rules:
- if: "$CI_COMMIT_BRANCH != $CI_DEFAULT_BRANCH"
build_site:
image: rust:latest
stage: build_site
script:
- cargo run
- mv output public
artifacts:
paths:
- public
pages:
stage: deploy
script:
- echo "Publishing site..."
dependencies:
- build_site
artifacts:
paths:
- public
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
indexnow:
stage: notify
needs:
- deploy
script:
- |
curl -X POST "https://api.indexnow.org/indexnow" \
-H "Content-Type: application/json" \
-d '{
"host": "https://zine.ansonbiggs.com",
"key": "2433b0850f38472a9dab36367deb89fc",
"urlList": ["https://zine.ansonbiggs.com", "https://zine.ansonbiggs.com/feed.xml"],
"keyLocation": "https://zine.ansonbiggs.com/2433b0850f38472a9dab36367deb89fc.txt"
}'
workflow:
name: $CI_COMMIT_REF_NAME
rules:
- if: $SCHEDULED_BUILD_PIPELINE == 'true'
variables:
CI_COMMIT_REF_NAME: $SCHEDULED_PIPELINE_NAME
- if: $SCHEDULED_BUILD_PIPELINE != 'true'
variables:
CI_COMMIT_REF_NAME: $DEFAULT_PIPELINE_NAME