Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pack cli to v0.19.0 and honor env-files input #9

Merged
merged 6 commits into from
Jun 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .env.ci
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
EXAMPLE=value
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ jobs:
path: 'samples/apps/bash-script/'
builder: 'cnbs/sample-builder:bionic'
env: 'HELLO=WORLD FOO=BAR BAZ'
env_files: '.env.ci'
id: build

- name: Show build command
run: echo ${{ steps.build.outputs.command }}

Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM docker:20.10.3-dind

ENV VERSION=v0.17.0
ENV VERSION=v0.19.0

RUN apk add --update --no-cache curl bash && \
curl -LO https://github.com/buildpacks/pack/releases/download/${VERSION}/pack-${VERSION}-linux.tgz && \
Expand Down
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,11 @@ on: [push]
## Inputs
- `image` : (required) Name of container image.
- `tag` : (optional) Tag of container image. Default `latest`
- `path` : (required) Path to target application.
- `path` : (optional) Path to target application, defaults to the current directory.
- `builder` : (required) Builder to use.
- `buildpacks` : (optional) URLs or Paths to Custom buildpacks, space separated.
- `env` : (optional) Environment variables, space separated.
- `env_files` : (optional) Files containing build time environment variables, space separated.

> See "[Cloud Native Buildpack Documentation · Environment variables](https://buildpacks.io/docs/app-developer-guide/environment-variables/)" for environment valiables.

Expand All @@ -52,4 +53,4 @@ on: [push]
path: 'samples/apps/java-maven/'
builder: 'cnbs/sample-builder:alpine'
buildpacks: 'samples/buildpacks/java-maven samples/buildpacks/hello-processes/ cnbs/sample-package:hello-universe'
```
```
8 changes: 6 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,9 @@ inputs:
default: 'latest'
required: false
path:
description: 'Path to target application'
required: true
description: 'Path to target application, defaults to the current directory'
default: '.'
required: false
builder:
description: 'Builder to use'
required: true
Expand All @@ -24,6 +25,9 @@ inputs:
env:
description: 'Build-time environment variables'
required: false
env_files:
description: 'Read build-time environment variables from these files'
required: false
outputs:
command:
description: 'build command executed'
Expand Down
12 changes: 11 additions & 1 deletion entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ if [ -n "$INPUT_ENV" ]; then
done
fi

env_files_str=""
if [ -n "$INPUT_ENV_FILES" ]; then
arr=(${INPUT_ENV_FILES})
for e in "${arr[@]}"
do
env_files_str+=" --env-file "
env_files_str+='"'$e'"'
done
fi

buildpacks=""
if [ -n "$INPUT_BUILDPACKS" ]; then
arr=(${INPUT_BUILDPACKS})
Expand All @@ -22,7 +32,7 @@ if [ -n "$INPUT_BUILDPACKS" ]; then
done
fi

command="pack build ${INPUT_IMAGE}:${INPUT_TAG} ${env_str} --path ${INPUT_PATH} ${buildpacks} --builder ${INPUT_BUILDER}"
command="pack build ${INPUT_IMAGE}:${INPUT_TAG} ${env_str} ${env_files_str} --path ${INPUT_PATH} ${buildpacks} --builder ${INPUT_BUILDER}"
echo "::set-output name=command::${command}"

sh -c "${command}"