resume-manpage/.woodpecker/cd.yml
bdeshi 325b62634a
All checks were successful
ci/woodpecker/push/cd Pipeline was successful
ci: reduce cache duplication
2024-06-01 04:33:08 +06:00

84 lines
1.8 KiB
YAML

---
# https://woodpecker-ci.org/docs/intro
when:
event: [push, manual]
variables:
images:
- &image_node node:18.16.0
- &image_aws_cli amazon/aws-cli:2.15.50
- &image_drone_cache meltwater/drone-cache:v1.4.0
deploy_secrets: &deploy_secrets
- S3_BUCKET
- CLOUDFRONT_DISTRIBUTION
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- AWS_REGION
cache_step: &cache_step
image: *image_drone_cache
environment:
AWS_ACCESS_KEY_ID:
from_secret: CACHE_S3_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY:
from_secret: CACHE_S3_SECRET_ACCESS_KEY
cache_settings: &cache_settings
cache_key: '{{ checksum "yarn.lock" }}'
archive_format: zstd
bucket:
from_secret: CACHE_S3_BUCKET
endpoint:
from_secret: CACHE_S3_ENDPOINT
region:
from_secret: CACHE_S3_REGION
path_style:
from_secret: CACHE_S3_USE_PATH_STYLE
mount:
- 'node_modules'
steps:
- name: cache/restore
<<: *cache_step
settings:
<<: *cache_settings
restore: true
- name: build/nodejs
depends_on: [cache/restore]
image: *image_node
commands:
- corepack enable yarn
- yarn install --prefer-offline
- yarn run build
- name: cache/rebuild
depends_on: [build/nodejs]
<<: *cache_step
settings:
<<: *cache_settings
rebuild: true
- name: publish/s3
depends_on: [build/nodejs]
when:
- branch: main
secrets: *deploy_secrets
image: *image_aws_cli
commands:
- aws s3 sync --delete ./dist "s3://$${S3_BUCKET}/"
- name: publish/cloudfront
depends_on: [publish/s3]
when:
- branch: main
secrets: *deploy_secrets
image: *image_aws_cli
commands:
- aws cloudfront create-invalidation --distribution-id
"$${CLOUDFRONT_DISTRIBUTION}" --paths '/*'