ci: refactor
Some checks failed
ci/woodpecker/push/cd Pipeline failed

This commit is contained in:
bdeshi 2024-06-01 04:31:34 +06:00
parent f8a3cb48dd
commit 5c72daf88c
Signed by: bdeshi
GPG Key ID: 410D03DA9A3468E0

View File

@ -1,3 +1,4 @@
---
# https://woodpecker-ci.org/docs/intro
when:
@ -5,23 +6,28 @@ when:
variables:
secrets: &secrets
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: &cache_step
image: meltwater/drone-cache:v1.4.0
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_step_settings
cache_key: '{{ .Commit.Branch }}-{{ checksum "yarn.lock" }}'
cache_settings: &cache_settings
cache_key: '{{ .Commit.Branch }}/{{ checksum "yarn.lock" }}'
archive_format: zstd
bucket:
from_secret: CACHE_S3_BUCKET
@ -34,46 +40,44 @@ variables:
mount:
- 'node_modules'
steps:
- name: cache/restore
<<: *cache_step
settings:
<<: *cache_step_settings
<<: *cache_settings
restore: true
- name: build/yarn
- name: build/nodejs
depends_on: [cache/restore]
image: node:18.16.0
image: *image_node
commands:
- yarn install
- yarn build
- corepack enable yarn
- yarn install --prefer-offline
- yarn run build
- name: cache/rebuild
depends_on: [ build/yarn ]
depends_on: [build/nodejs]
<<: *cache_step
settings:
<<: *cache_step_settings
<<: *cache_settings
rebuild: true
- name: publish/s3
depends_on: [ build/yarn ]
depends_on: [build/nodejs]
when:
- branch: main
image: amazon/aws-cli:2.15.50
secrets: *deploy_secrets
image: *image_aws_cli
commands:
- aws s3 sync --delete ./dist s3://$${S3_BUCKET}/
secrets:
- <<: *secrets
- aws s3 sync --delete ./dist "s3://$${S3_BUCKET}/"
- name: publish/cloudfront
depends_on: [publish/s3]
when:
- branch: main
image: amazon/aws-cli:2.15.50
secrets: *deploy_secrets
image: *image_aws_cli
commands:
- aws cloudfront create-invalidation --distribution-id $${CLOUDFRONT_DISTRIBUTION} --paths '/*'
secrets:
- <<: *secrets
- aws cloudfront create-invalidation --distribution-id
"$${CLOUDFRONT_DISTRIBUTION}" --paths '/*'