Skip to content

Instantly share code, notes, and snippets.

@wangpin34
Last active January 12, 2022 02:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wangpin34/e8ae328414ad5239b50dcda89546f15b to your computer and use it in GitHub Desktop.
Save wangpin34/e8ae328414ad5239b50dcda89546f15b to your computer and use it in GitHub Desktop.
tekton tasks
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