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-05-17 11:06:14 +06:00
|
|
|
secrets: &secrets
|
|
|
|
- S3_BUCKET
|
|
|
|
- CLOUDFRONT_DISTRIBUTION
|
|
|
|
- AWS_ACCESS_KEY_ID
|
|
|
|
- AWS_SECRET_ACCESS_KEY
|
|
|
|
- AWS_REGION
|
|
|
|
|
2024-05-20 22:14:21 +06:00
|
|
|
cache: &cache_step
|
2024-05-20 20:56:49 +06:00
|
|
|
image: meltwater/drone-cache:v1.4.0
|
|
|
|
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
|
|
|
|
|
|
|
cache_settings: &cache_step_settings
|
|
|
|
cache_key: '{{ .Commit.Branch }}-{{ checksum "yarn.lock" }}'
|
|
|
|
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:
|
|
|
|
- name: cache/restore
|
|
|
|
<<: *cache_step
|
2024-05-20 20:56:49 +06:00
|
|
|
settings:
|
2024-05-20 22:14:21 +06:00
|
|
|
<<: *cache_step_settings
|
2024-05-20 20:56:49 +06:00
|
|
|
restore: true
|
2024-05-20 22:14:21 +06:00
|
|
|
|
2024-05-20 20:56:49 +06:00
|
|
|
|
2024-05-17 11:06:14 +06:00
|
|
|
- name: build/yarn
|
2024-05-20 20:56:49 +06:00
|
|
|
depends_on: [ cache/restore ]
|
2024-05-17 11:06:14 +06:00
|
|
|
image: node:18
|
|
|
|
commands:
|
|
|
|
- yarn install
|
|
|
|
- yarn build
|
|
|
|
|
2024-05-20 20:56:49 +06:00
|
|
|
- name: cache/rebuild
|
|
|
|
depends_on: [ build/yarn ]
|
2024-05-20 22:14:21 +06:00
|
|
|
<<: *cache_step
|
2024-05-20 20:56:49 +06:00
|
|
|
settings:
|
2024-05-20 22:14:21 +06:00
|
|
|
<<: *cache_step_settings
|
2024-05-20 20:56:49 +06:00
|
|
|
rebuild: true
|
2024-05-20 22:14:21 +06:00
|
|
|
|
2024-05-20 20:56:49 +06:00
|
|
|
|
2024-05-17 11:06:14 +06:00
|
|
|
- name: publish/s3
|
2024-05-20 20:51:29 +06:00
|
|
|
depends_on: [ build/yarn ]
|
|
|
|
when:
|
|
|
|
- branch: main
|
2024-05-17 11:06:14 +06:00
|
|
|
image: amazon/aws-cli:2.15.50
|
|
|
|
commands:
|
|
|
|
- aws s3 sync --delete ./dist s3://$${S3_BUCKET}/
|
|
|
|
secrets:
|
|
|
|
- <<: *secrets
|
|
|
|
|
|
|
|
- name: publish/cloudfront
|
2024-05-20 20:51:29 +06:00
|
|
|
depends_on: [ publish/s3 ]
|
|
|
|
when:
|
|
|
|
- branch: main
|
2024-05-17 11:06:14 +06:00
|
|
|
image: amazon/aws-cli:2.15.50
|
|
|
|
commands:
|
|
|
|
- aws cloudfront create-invalidation --distribution-id $${CLOUDFRONT_DISTRIBUTION} --paths '/*'
|
|
|
|
secrets:
|
|
|
|
- <<: *secrets
|