-
Notifications
You must be signed in to change notification settings - Fork 579
/
Copy path02-build-archive.yaml
48 lines (48 loc) · 1.95 KB
/
02-build-archive.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# Task to build archive with an application source
#
# Inputs:
# * app-git: GitHub Repo with application source
# * OW_APP_PYTHON_VERSION: any specific Python version, e.g. "python:3.6", or "python:3.7", etc default is "python"
# * OW_APP_PATH: path to the application source within GitHub repo
# * OW_ACTION_ARCHIVE_NAME: default is action.zip
#
# This task creates archive with everything from the application path
#
apiVersion: tekton.dev/v1beta1
kind: Task
metadata:
name: task-build-archive-python
spec:
workspaces:
- name: openwhisk-workspace
params:
- name: OW_APP_PYTHON_VERSION
default: "python"
- name: OW_APP_PATH
default: ""
- name: OW_ACTION_ARCHIVE_NAME
default: "action.zip"
steps:
- name: build-action-archive
image: $(params.OW_APP_PYTHON_VERSION)
script: |
#!/usr/bin/env bash
set -xe
echo $(params.OW_APP_PATH)
apt-get update && apt-get install zip
OW_APP_PATH=$(workspaces.openwhisk-workspace.path)/application/$(params.OW_APP_PATH)
cd $OW_APP_PATH
echo "Starting to create an archive under $OW_APP_PATH"
# exclude all dist-info and default packages from archive
excluded_pkgs=$(cat virtualenv/site-packages.lst | sed -n -e 'H;${x;s/\n/|/g;s/^|//;p;}')
included_pkgs=$(ls -d virtualenv/lib/python3.*/site-packages/* | grep -Ev $excluded_pkgs | grep -v '.dist-info' | grep -v '__pycache__')
echo $included_pkgs
# grab all non-git or virtualenv related files
app_files=$(ls * | grep -Ev 'virtualenv|^\.git')
echo $app_files
zip -r $(params.OW_ACTION_ARCHIVE_NAME) $included_pkgs $app_files virtualenv/bin/activate_this.py
if [ $? = 0 ]; then
echo "Successfully built and created $(params.OW_ACTION_ARCHIVE_NAME) under $OW_APP_PATH"
else
echo "Failed to build and archive action source into $(params.OW_ACTION_ARCHIVE_NAME) under $OW_APP_PATH"
fi