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..b821cd949 --- /dev/null +++ b/github-action-workflows/my-ce-app/build-push.yml @@ -0,0 +1,29 @@ +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 + id: build-step + 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' + - name: Get image with digest + run: | + echo "Image with digest: ${{ steps.build-step.outputs.image-with-digest }}" \ 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