From a8861775cfb6d89acfa2fce75dabf8fe5cd1ebe4 Mon Sep 17 00:00:00 2001 From: Luke Roy Date: Mon, 24 Nov 2025 18:46:24 +0100 Subject: [PATCH 1/2] Add new GitHub Action Workflows from Blogpost Signed-off-by: Luke Roy --- github-action-workflows/README.md | 6 ++-- .../my-ce-app/build-push.yml | 25 ++++++++++++++++ .../my-docker-app/Dockerfile | 15 ++++++++++ .../my-docker-app/build-dockerfile-app.yml | 30 +++++++++++++++++++ github-action-workflows/my-docker-app/main.go | 16 ++++++++++ .../my-img-app/my-img-app.yml | 28 +++++++++++++++++ 6 files changed, 118 insertions(+), 2 deletions(-) create mode 100644 github-action-workflows/my-ce-app/build-push.yml create mode 100644 github-action-workflows/my-docker-app/Dockerfile create mode 100644 github-action-workflows/my-docker-app/build-dockerfile-app.yml create mode 100644 github-action-workflows/my-docker-app/main.go create mode 100644 github-action-workflows/my-img-app/my-img-app.yml diff --git a/github-action-workflows/README.md b/github-action-workflows/README.md index 3988a2e5b..b2cf4c054 100644 --- a/github-action-workflows/README.md +++ b/github-action-workflows/README.md @@ -1,6 +1,8 @@ # Source Code for the IBM Cloud Code Engine: Deploying Apps, Jobs and Functions using GitHub Actions Blog post -This folder contains the source code used in the [IBM Cloud Code Engine: Deploying Apps, Jobs and Functions using GitHub Actions](https://community.ibm.com/community/user/blogs/luke-roy/2024/02/12/ibm-cloud-code-engine-deploying-apps-jobs-and-func) Blog Post. +This folder contains the source code used in the [IBM Cloud Code Engine: Deploying Apps, Jobs and Functions using GitHub Actions](https://community.ibm.com/community/user/blogs/luke-roy/2024/02/12/ibm-cloud-code-engine-deploying-apps-jobs-and-func) and the [IBM Cloud Code Engine GitHub Action: Getting into the Cloud just got a lot easier!](https://community.ibm.com/community/user/blogs/luke-roy/2025/11/24/ibm-cloud-code-engine-github-action-easier) Blog Posts -- [App](github-action-workflows/my-ce-app) +- [App,Build](github-action-workflows/my-ce-app) +- [Docker App](github-action-workflows/my-docker-app) +- [Image App](github-action-workflows/my-img-app) - [Python Function](github-action-workflows/my-ce-py-func) \ No newline at end of file diff --git a/github-action-workflows/my-ce-app/build-push.yml b/github-action-workflows/my-ce-app/build-push.yml new file mode 100644 index 000000000..5c39d1c93 --- /dev/null +++ b/github-action-workflows/my-ce-app/build-push.yml @@ -0,0 +1,25 @@ +name: Build and Push to ICR + +on: + push: + branches: + - main + +jobs: + app: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Build and Push to ICR + uses: ibm/code-engine-github-action@v1 + with: + api-key: ${{ secrets.IBM_IAM_API_KEY }} + region: 'eu-de' + project: 'MY-PROJECT' + component: 'build' + name: 'my-ce-app' + image: private.de.icr.io/my-namespace/my-image:latest + registry-secret: ce-auto-icr-private-eu-de + build-source: './my-ce-app' \ No newline at end of file diff --git a/github-action-workflows/my-docker-app/Dockerfile b/github-action-workflows/my-docker-app/Dockerfile new file mode 100644 index 000000000..a53166f48 --- /dev/null +++ b/github-action-workflows/my-docker-app/Dockerfile @@ -0,0 +1,15 @@ +FROM quay.io/projectquay/golang:1.24 AS build-env + +WORKDIR /go/src/app + +COPY main.go main.go + +RUN CGO_ENABLED=0 go build -o /go/bin/app main.go + +FROM gcr.io/distroless/static-debian12 + +EXPOSE 3000 + +COPY --from=build-env /go/bin/app / + +ENTRYPOINT ["/app"] \ No newline at end of file diff --git a/github-action-workflows/my-docker-app/build-dockerfile-app.yml b/github-action-workflows/my-docker-app/build-dockerfile-app.yml new file mode 100644 index 000000000..0c447ead9 --- /dev/null +++ b/github-action-workflows/my-docker-app/build-dockerfile-app.yml @@ -0,0 +1,30 @@ +name: Deploy App to Code Engine using Dockerfile build-strategy + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + + deploy-app: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Deploy App to Code Engine using Dockerfile build-strategy + uses: IBM/code-engine-github-action@v1 + with: + api-key: ${{ secrets.IBM_IAM_API_KEY }} + resource-group: 'Default' + region: 'eu-de' + project: 'MY-PROJECT' + component: 'app' + build-strategy: 'dockerfile' + port: 3000 + name: 'my-docker-app' + build-source: './my-docker-app' + cpu: 1 + memory: 4G \ No newline at end of file diff --git a/github-action-workflows/my-docker-app/main.go b/github-action-workflows/my-docker-app/main.go new file mode 100644 index 000000000..481428424 --- /dev/null +++ b/github-action-workflows/my-docker-app/main.go @@ -0,0 +1,16 @@ +package main + +import ( + "fmt" + "net/http" + "time" +) + +func greet(w http.ResponseWriter, r *http.Request) { + fmt.Fprintf(w, "Hello World! %s", time.Now()) +} + +func main() { + http.HandleFunc("/", greet) + http.ListenAndServe(":3000", nil) +} \ No newline at end of file diff --git a/github-action-workflows/my-img-app/my-img-app.yml b/github-action-workflows/my-img-app/my-img-app.yml new file mode 100644 index 000000000..10e8b7d72 --- /dev/null +++ b/github-action-workflows/my-img-app/my-img-app.yml @@ -0,0 +1,28 @@ +name: Deploy Application to Code Engine using existing container image + +on: + push: + branches: + - main + workflow_dispatch: + +jobs: + + deploy-app: + runs-on: ubuntu-latest + steps: + - name: Check out code + uses: actions/checkout@v3 + + - name: Deploy Application to Code Engine using existing container image + uses: IBM/code-engine-github-action@v1 + with: + api-key: ${{ secrets.IBM_IAM_API_KEY }} + resource-group: 'Default' + region: 'eu-de' + project: 'MY-PROJECT' + component: 'app' + name: 'my-img-app' + image: icr.io/codeengine/helloworld:latest + cpu: 1 + memory: 4G \ No newline at end of file From 56b975c52649ca9e75f96ba030e065b12a948538 Mon Sep 17 00:00:00 2001 From: Luke Roy Date: Wed, 26 Nov 2025 09:06:55 +0100 Subject: [PATCH 2/2] add image output Signed-off-by: Luke Roy --- github-action-workflows/my-ce-app/build-push.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/github-action-workflows/my-ce-app/build-push.yml b/github-action-workflows/my-ce-app/build-push.yml index 5c39d1c93..b821cd949 100644 --- a/github-action-workflows/my-ce-app/build-push.yml +++ b/github-action-workflows/my-ce-app/build-push.yml @@ -13,6 +13,7 @@ jobs: uses: actions/checkout@v3 - name: Build and Push to ICR + id: build-step uses: ibm/code-engine-github-action@v1 with: api-key: ${{ secrets.IBM_IAM_API_KEY }} @@ -22,4 +23,7 @@ jobs: name: 'my-ce-app' image: private.de.icr.io/my-namespace/my-image:latest registry-secret: ce-auto-icr-private-eu-de - build-source: './my-ce-app' \ No newline at end of file + build-source: './my-ce-app' + - name: Get image with digest + run: | + echo "Image with digest: ${{ steps.build-step.outputs.image-with-digest }}" \ No newline at end of file