Skip to content

Commit

Permalink
host enabled in wf? (#17)
Browse files Browse the repository at this point in the history
* host enabled in wf?

* host enabled in wf?2

* func build init

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* remove fail fast and specify pack build default

* remove fail fast and specify pack build default

* HOST_ENABLED in bash

* HOST_ENABLED in bash

* fix

Signed-off-by: David Fridrich <[email protected]>

* fix

Signed-off-by: David Fridrich <[email protected]>

* test jq approach

* test jq approach

* test jq approach

* fixu

* fixup

---------

Signed-off-by: David Fridrich <[email protected]>
  • Loading branch information
gauron99 authored Dec 12, 2024
1 parent 0466f3c commit a84ebe8
Showing 1 changed file with 32 additions and 6 deletions.
38 changes: 32 additions & 6 deletions .github/workflows/build-all.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,15 @@ jobs:
needs: prepare
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
language: ${{ fromJSON(needs.prepare.outputs.languages) }}
env:
ACTIONS_STEP_DEBUG: true
language_paths: ${{needs.prepare.outputs.language_paths}}
# UPDATE THIS IF HOST BUILDER IS ENABLED FOR MORE LANGUAGES
HOST_ENABLED_LANGUAGES: '["go"]'
HEADREF: ${{github.head_ref}}
steps:
- name: Checkout code
uses: actions/checkout@v4
Expand All @@ -45,26 +49,48 @@ jobs:
version: ${{ env.FUNC_VERSION }}
name: f

- name: Build Functions
- name: Deploy Function
run: |
# DETERMINE IF HOST BUILDER SHOULD BE USED
## NOTE: HOST_ENABLED_LANGUAGES MUST BE UP TO DATE
if echo '${{env.HOST_ENABLED_LANGUAGES}}' | jq -r ".[] | select(. == \"${{matrix.language}}\")" | grep -q .; then
HOST_ENABLED=true
else
HOST_ENABLED=false
fi
language=${{matrix.language}}
echo "Current language: $language"
echo "Current language is $language"
echo "host enabled? $HOST_ENABLED"
# This takes the array of paths, wraps it in single quotes for jq, then
# selects only the value that matches with language to get current
# language AND its full path (where the func template is)
language_path=$(echo '${{env.language_paths}}' | jq -r ".[] | select(contains(\"${{matrix.language}}\"))")
## use the Pull request environment so that the changes are included in testing
url="https://github.com/gauron99/func-templates#${{ github.head_ref }}"
url="https://github.com/gauron99/func-templates#${{ env.HEADREF }}"
WORKDIR=$(mktemp -d)
cd $WORKDIR
echo "Building funcs in language ${{matrix.language}}"
for template_dir_abs in $(ls -d $language_path*/); do
echo "ls -la ${GITHUB_WORKSPACE}"
ls -la ${GITHUB_WORKSPACE}
template=$(basename "$template_dir_abs")
## FUNC CREATE
echo "> FUNC CREATE"
echo "f create $language-$template -r=$url -l=$language -t=$template"
f create $language-$template -r "$url" -l "$language" -t "$template"
#FUNC_ENABLE_HOST_BUILDER=1 FUNC_BUILDER=host FUNC_CONTAINER=false FUNC_REGISTRY=docker.io/4141gauron3268 f
cd $language-$template
## FUNC BUILD
echo "> FUNC BUILD"
if $HOST_ENABLED; then
echo "build with host"
FUNC_ENABLE_HOST_BUILDER=1 FUNC_BUILDER=host FUNC_CONTAINER=false FUNC_REGISTRY=docker.io/4141gauron3268 f build
else
echo "build with pack"
FUNC_REGISTRY=docker.io/4141gauron3268 f build --builder=pack
fi
done

0 comments on commit a84ebe8

Please sign in to comment.