Skip to content

Commit

Permalink
add Examples for blog
Browse files Browse the repository at this point in the history
Signed-off-by: Luke Roy <[email protected]>
  • Loading branch information
Luke-Roy-IBM committed Feb 20, 2024
1 parent fb51646 commit 5d844f3
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 0 deletions.
6 changes: 6 additions & 0 deletions github-action-workflows/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# 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.

- [App](github-action-workflows/my-ce-app)
- [Python Function](github-action-workflows/my-ce-py-func)
22 changes: 22 additions & 0 deletions github-action-workflows/my-ce-app/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
const express = require("express");

const app = express();
const port = 8080;
app.use(express.urlencoded({ extended: true }));
app.use(express.json());

app.get("/", (req, res) => {
res.setHeader("Content-Type", "application/json");
res.status(200).send(JSON.stringify({ body: "Hello from Node" }));
});

const server = app.listen(port, () => {
console.log(`Example app listening at http://localhost:${port}`);
});

process.on("SIGTERM", () => {
console.info("SIGTERM signal received.");
server.close(() => {
console.log("Http server closed.");
});
});
23 changes: 23 additions & 0 deletions github-action-workflows/my-ce-app/deploy-ce-app.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: Deploy App to Code Engine

on:
push:
branches:
- main

jobs:
app:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Deploy Application to Code Engine
uses: ibm/code-engine-github-action@v1
with:
api-key: ${{ secrets.IBM_IAM_API_KEY }}
region: 'eu-de'
project: 'MY-PROJECT'
component: 'app'
name: 'my-ce-app'
build-source: './my-ce-app'
5 changes: 5 additions & 0 deletions github-action-workflows/my-ce-app/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"dependencies": {
"express": "^4.17.1"
}
}
11 changes: 11 additions & 0 deletions github-action-workflows/my-ce-py-func/__main__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
from lorem_text import lorem

def main(params):
words = 10

return {
"headers": {
"Content-Type": "text/plain;charset=utf-8",
},
"body": lorem.words(words),
}
25 changes: 25 additions & 0 deletions github-action-workflows/my-ce-py-func/deploy-ce-py-func.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Deploy Python Function to Code Engine

on:
push:
branches:
- main

jobs:

fn-py:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Deploy Python Function to Code Engine
uses: ibm/code-engine-github-action@v1
with:
api-key: ${{ secrets.IBM_IAM_API_KEY }}
region: 'eu-de'
project: 'MY-PROJECT'
component: 'fn'
runtime: python-3.11
name: 'my-ce-py-fn'
build-source: './my-ce-py-func'
1 change: 1 addition & 0 deletions github-action-workflows/my-ce-py-func/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
lorem-text

0 comments on commit 5d844f3

Please sign in to comment.