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