Last active
January 12, 2022 02:51
-
-
Save wangpin34/e8ae328414ad5239b50dcda89546f15b to your computer and use it in GitHub Desktop.
tekton tasks
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apiVersion: tekton.dev/v1beta1 | |
kind: Task | |
metadata: | |
name: deploy-web-to-s3 | |
namespace: default | |
spec: | |
params: | |
- name: build_command | |
type: string | |
default: npm build | |
- name: output_dir | |
type: string | |
default: dist | |
- name: s3_bucket_name | |
type: string | |
- name: env | |
type: string | |
default: "" | |
- name: aws_region | |
type: string | |
default: us-west-2 | |
- name: aws_access_key_id | |
type: string | |
- name: aws_secret_access_key | |
type: string | |
resources: | |
inputs: | |
- name: repo | |
type: git | |
targetPath: repo | |
stepTemplate: | |
image: node:16.13.1-stretch | |
workingDir: /workspace/repo | |
steps: | |
- name: setup | |
command: | |
- /bin/sh | |
- -c | |
args: | |
- npm install | |
- name: config-env | |
command: | |
- /bin/sh | |
- -c | |
args: | |
- echo $(params.env) > .env | |
- name: build | |
command: | |
- /bin/sh | |
- -c | |
args: | |
- "$(params.build_command)" | |
- name: deploy | |
script: | | |
#!/usr/bin/env bash | |
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip" | |
unzip awscliv2.zip | |
./aws/install | |
aws configure set region ${params.aws_region} | |
aws configure set aws_access_key_id $(params.aws_access_key_id) | |
aws configure set aws_secret_access_key $(params.aws_secret_access_key) | |
echo "start uploading assets to s3://$(params.s3_bucket_name) from ./$(params.output_dir)" | |
aws s3 sync $(params.output_dir) "s3://$(params.s3_bucket_name)" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment