-
Notifications
You must be signed in to change notification settings - Fork 126
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Luke Roy <[email protected]>
- Loading branch information
1 parent
fb51646
commit 5d844f3
Showing
7 changed files
with
93 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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."); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"dependencies": { | ||
"express": "^4.17.1" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
25
github-action-workflows/my-ce-py-func/deploy-ce-py-func.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lorem-text |