Skip to content

Commit

Permalink
added builder gh action, added slack-collector and slack-notify appli…
Browse files Browse the repository at this point in the history
…cations
  • Loading branch information
ca7alindev committed Sep 24, 2024
1 parent 108127e commit 84c6e3e
Show file tree
Hide file tree
Showing 19 changed files with 782 additions and 299 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/builder.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Builder
on:
push:
branches:
- main

defaults:
run:
shell: bash

env:
REGISTRY: ghcr.io

jobs:
build-and-pack:
name: Build and pack
runs-on: ubuntu-latest
permissions:
contents: write
packages: write

steps:
- name: CR authentication
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 2
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "[email protected]"
- name: Get Short GitHub SHA and Save in Environment Variable
run: echo "SHORT_GITHUB_SHA=$(git rev-parse --short=5 HEAD)" >> $GITHUB_ENV

- name: Setup the Crossplane CLI
run: "curl -sL https://raw.githubusercontent.com/crossplane/crossplane/master/install.sh | sh"

- name: Build and push slack-collector
run: docker build -f internal/slack-collector/Dockerfile . -t ${REGISTRY}/${{ github.repository }}/slack-collector:${SHORT_GITHUB_SHA} && docker push ${REGISTRY}/${{ github.repository }}/slack-collector:${SHORT_GITHUB_SHA}

- name: Build and push slack-notify
run: docker build -f internal/slack-notify/Dockerfile . -t ${REGISTRY}/${{ github.repository }}/slack-notify:${SHORT_GITHUB_SHA} && docker push ${REGISTRY}/${{ github.repository }}/slack-notify:${SHORT_GITHUB_SHA}

- name: Build function image
run: docker build . -t ${REGISTRY}/${{ github.repository }}:${SHORT_GITHUB_SHA}

- name: Build ans push Package
run: ./crossplane xpkg build --package-file=function-poll.xpkg --package-root=package/ --embed-runtime-image=${REGISTRY}/${{ github.repository }}:${SHORT_GITHUB_SHA} && ./crossplane xpkg push -f function-poll.xpkg ${REGISTRY}/${{ github.repository }}:${SHORT_GITHUB_SHA}

1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ RUN --mount=target=. \
# Produce the Function image. We use a very lightweight 'distroless' image that
# does not include any of the build tools used in previous stages.
FROM gcr.io/distroless/base-debian11 AS image
LABEL org.opencontainers.image.source=https://github.com/kndpio/function-poll
WORKDIR /
COPY --from=build /function /function
EXPOSE 9443
Expand Down
16 changes: 10 additions & 6 deletions example/composition.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
apiVersion: apiextensions.crossplane.io/v1
kind: Composition
metadata:
name: function-template-go
name: poll-composition
spec:
compositeTypeRef:
apiVersion: example.crossplane.io/v1
kind: XR
apiVersion: kndp.io/v1alpha1
kind: Poll
mode: Pipeline
pipeline:
- step: run-the-template
functionRef:
name: function-template-go
input:
providerConfigRef: "default"
deploymentName: "collect"
deploymentImage: "ghcr.io/kndpio/kndp/slack-collector:0.1.0"
apiVersion: kndp.io/v1alpha1
kind: Poll
providerConfigRef: "kndp-kubernetes-provider-config"
deploymentImage: "ghcr.io/kndpio/function-poll/slack-collector:d7a4b"
cronJobImage: "ghcr.io/kndpio/function-poll/slack-notify:d7a4b"
deploymentName: "slack-collector"
serviceAccountName: "slack-collector"
3 changes: 0 additions & 3 deletions example/function-runtime.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@ kind: DeploymentRuntimeConfig
metadata:
name: poll-function-runtime
spec:
serviceAccountTemplate:
metadata:
name: poll-sa
deploymentTemplate:
spec:
selector:
Expand Down
4 changes: 2 additions & 2 deletions example/functions.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ metadata:
name: function-template-go
annotations:
# This tells crossplane beta render to connect to the function locally.
render.crossplane.io/runtime: Development
# render.crossplane.io/runtime: Development
spec:
# This is ignored when using the Development runtime.
package: function-template-go
package: ghcr.io/kndpio/function-poll:d7a4b
runtimeConfigRef:
name: poll-function-runtime
9 changes: 6 additions & 3 deletions package/rbac.yaml → example/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ rules:
resources: ["ingresses"]
verbs: ["*"]
- apiGroups: ["kndp.io"]
resources: ["meals"]
resources: ["polls"]
verbs: ["*"]
- apiGroups: ["kndp.io"]
resources: ["polls/status"]
verbs: ["*"]
- apiGroups: ["v1"]
resources: ["services"]
Expand All @@ -24,7 +27,7 @@ rules:
apiVersion: v1
kind: ServiceAccount
metadata:
name: poll-sa
name: slack-collector

---

Expand All @@ -34,7 +37,7 @@ metadata:
name: poll-cluster-role-binding
subjects:
- kind: ServiceAccount
name: poll-sa
name: slack-collector
namespace: default
roleRef:
kind: ClusterRole
Expand Down
12 changes: 6 additions & 6 deletions example/xr.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
apiVersion: kndp.io/v1alpha1
kind: Poll
metadata:
name: poll
name: meal
spec:
deliveryTime: ""
dueOrderTime: "3000"
dueTakeTime: ""
deliveryTime: 0
dueOrderTime: 15
dueTakeTime: 0
voters: []
status: ""
title: ""
title: "meal"
schedule: "0 * * * *"
messages:
question: "how are you?"
response: "thank you for response."
Expand Down
Loading

0 comments on commit 84c6e3e

Please sign in to comment.