2024-06-01 04:31:34 +06:00
|
|
|
---
|
2024-05-17 11:06:14 +06:00
|
|
|
# https://woodpecker-ci.org/docs/intro
|
|
|
|
|
|
|
|
when:
|
|
|
|
event: [push, manual]
|
|
|
|
|
|
|
|
variables:
|
2024-05-20 22:14:21 +06:00
|
|
|
|
2024-06-01 04:31:34 +06:00
|
|
|
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
|
2024-05-17 11:06:14 +06:00
|
|
|
- S3_BUCKET
|
|
|
|
- CLOUDFRONT_DISTRIBUTION
|
|
|
|
- AWS_ACCESS_KEY_ID
|
|
|
|
- AWS_SECRET_ACCESS_KEY
|
|
|
|
- AWS_REGION
|
|
|
|
|
2024-06-01 04:31:34 +06:00
|
|
|
cache_step: &cache_step
|
|
|
|
image: *image_drone_cache
|
2024-05-20 20:56:49 +06:00
|
|
|
environment:
|
|
|
|
AWS_ACCESS_KEY_ID:
|
|
|
|
from_secret: CACHE_S3_ACCESS_KEY_ID
|
|
|
|
AWS_SECRET_ACCESS_KEY:
|
|
|
|
from_secret: CACHE_S3_SECRET_ACCESS_KEY
|
2024-05-20 22:14:21 +06:00
|
|
|
|
2024-06-01 04:31:34 +06:00
|
|
|
cache_settings: &cache_settings
|
|
|
|
cache_key: '{{ .Commit.Branch }}/{{ checksum "yarn.lock" }}'
|
2024-05-20 22:14:21 +06:00
|
|
|
archive_format: zstd
|
|
|
|
bucket:
|
|
|
|
from_secret: CACHE_S3_BUCKET
|
|
|
|
endpoint:
|
|
|
|
from_secret: CACHE_S3_ENDPOINT
|
|
|
|
region:
|
|
|
|
from_secret: CACHE_S3_REGION
|
2024-05-31 05:55:39 +06:00
|
|
|
path_style:
|
|
|
|
from_secret: CACHE_S3_USE_PATH_STYLE
|
2024-05-20 22:14:21 +06:00
|
|
|
mount:
|
|
|
|
- 'node_modules'
|
|
|
|
|
|
|
|
steps:
|
2024-06-01 04:31:34 +06:00
|
|
|
|
2024-05-20 22:14:21 +06:00
|
|
|
- name: cache/restore
|
|
|
|
<<: *cache_step
|
2024-05-20 20:56:49 +06:00
|
|
|
settings:
|
2024-06-01 04:31:34 +06:00
|
|
|
<<: *cache_settings
|
2024-05-20 20:56:49 +06:00
|
|
|
restore: true
|
2024-05-20 22:14:21 +06:00
|
|
|
|
2024-06-01 04:31:34 +06:00
|
|
|
- name: build/nodejs
|
|
|
|
depends_on: [cache/restore]
|
|
|
|
image: *image_node
|
2024-05-17 11:06:14 +06:00
|
|
|
commands:
|
2024-06-01 04:31:34 +06:00
|
|
|
- corepack enable yarn
|
|
|
|
- yarn install --prefer-offline
|
|
|
|
- yarn run build
|
2024-05-17 11:06:14 +06:00
|
|
|
|
2024-05-20 20:56:49 +06:00
|
|
|
- name: cache/rebuild
|
2024-06-01 04:31:34 +06:00
|
|
|
depends_on: [build/nodejs]
|
2024-05-20 22:14:21 +06:00
|
|
|
<<: *cache_step
|
2024-05-20 20:56:49 +06:00
|
|
|
settings:
|
2024-06-01 04:31:34 +06:00
|
|
|
<<: *cache_settings
|
2024-05-20 20:56:49 +06:00
|
|
|
rebuild: true
|
2024-05-20 22:14:21 +06:00
|
|
|
|
2024-05-17 11:06:14 +06:00
|
|
|
- name: publish/s3
|
2024-06-01 04:31:34 +06:00
|
|
|
depends_on: [build/nodejs]
|
2024-05-20 20:51:29 +06:00
|
|
|
when:
|
|
|
|
- branch: main
|
2024-06-01 04:31:34 +06:00
|
|
|
secrets: *deploy_secrets
|
|
|
|
image: *image_aws_cli
|
2024-05-17 11:06:14 +06:00
|
|
|
commands:
|
2024-06-01 04:31:34 +06:00
|
|
|
- aws s3 sync --delete ./dist "s3://$${S3_BUCKET}/"
|
2024-05-17 11:06:14 +06:00
|
|
|
|
|
|
|
- name: publish/cloudfront
|
2024-06-01 04:31:34 +06:00
|
|
|
depends_on: [publish/s3]
|
2024-05-20 20:51:29 +06:00
|
|
|
when:
|
|
|
|
- branch: main
|
2024-06-01 04:31:34 +06:00
|
|
|
secrets: *deploy_secrets
|
|
|
|
image: *image_aws_cli
|
2024-05-17 11:06:14 +06:00
|
|
|
commands:
|
2024-06-01 04:31:34 +06:00
|
|
|
- aws cloudfront create-invalidation --distribution-id
|
|
|
|
"$${CLOUDFRONT_DISTRIBUTION}" --paths '/*'
|