79 lines
1.6 KiB
YAML
79 lines
1.6 KiB
YAML
# https://woodpecker-ci.org/docs/intro
|
|
|
|
when:
|
|
event: [push, manual]
|
|
|
|
variables:
|
|
|
|
secrets: &secrets
|
|
- S3_BUCKET
|
|
- CLOUDFRONT_DISTRIBUTION
|
|
- AWS_ACCESS_KEY_ID
|
|
- AWS_SECRET_ACCESS_KEY
|
|
- AWS_REGION
|
|
|
|
cache: &cache_step
|
|
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
|
|
|
|
cache_settings: &cache_step_settings
|
|
path_style: true
|
|
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
|
|
mount:
|
|
- 'node_modules'
|
|
|
|
|
|
steps:
|
|
- name: cache/restore
|
|
<<: *cache_step
|
|
settings:
|
|
<<: *cache_step_settings
|
|
restore: true
|
|
|
|
|
|
- name: build/yarn
|
|
depends_on: [ cache/restore ]
|
|
image: node:18
|
|
commands:
|
|
- yarn install
|
|
- yarn build
|
|
|
|
- name: cache/rebuild
|
|
depends_on: [ build/yarn ]
|
|
<<: *cache_step
|
|
settings:
|
|
<<: *cache_step_settings
|
|
rebuild: true
|
|
|
|
|
|
- name: publish/s3
|
|
depends_on: [ build/yarn ]
|
|
when:
|
|
- branch: main
|
|
image: amazon/aws-cli:2.15.50
|
|
commands:
|
|
- aws s3 sync --delete ./dist s3://$${S3_BUCKET}/
|
|
secrets:
|
|
- <<: *secrets
|
|
|
|
- name: publish/cloudfront
|
|
depends_on: [ publish/s3 ]
|
|
when:
|
|
- branch: main
|
|
image: amazon/aws-cli:2.15.50
|
|
commands:
|
|
- aws cloudfront create-invalidation --distribution-id $${CLOUDFRONT_DISTRIBUTION} --paths '/*'
|
|
secrets:
|
|
- <<: *secrets
|