Skip to content

Commit

Permalink
Add workflow for update to new base-image (#249)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonJagger authored Jan 22, 2025
1 parent d0398aa commit f266b06
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 11 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/base_image_trigger.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Base Image Update

on:
workflow_dispatch:
inputs:
base_image:
description: "Image-Tag for cyberdojo/sinatra (short commit SHA - first 7 digits) eg edb2887"
required: true


jobs:
setup:
runs-on: ubuntu-latest
outputs:
base_image: ${{ steps.vars.outputs.base_image }}
kosli_trail: ${{ steps.vars.outputs.kosli_trail }}
steps:
- name: Outputs
id: vars
run: |
echo "base_image=cyberdojo/sinatra-base:${{ inputs.base_image }}" >> ${GITHUB_OUTPUT}
echo "kosli_trail=base-image-update-${{ inputs.base_image }}" >> ${GITHUB_OUTPUT}

trigger:
needs: [setup]
uses: ./.github/workflows/main.yml
with:
BASE_IMAGE: ${{ needs.setup.outputs.base_image }}
KOSLI_TRAIL: ${{ needs.setup.outputs.kosli_trail }}
secrets:
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASS: ${{ secrets.DOCKER_PASS }}
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }}
KOSLI_API_TOKEN: ${{ secrets.KOSLI_API_TOKEN }}

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ $ make demo
* [GET alive](docs/api.md#get-alive)
* [GET ready](docs/api.md#get-ready)
* [GET sha](docs/api.md#get-sha)
* [GET base_image](docs/api.md#get-base-image)
* ...

- - - -
Expand Down
35 changes: 24 additions & 11 deletions docs/api.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,29 @@
# API
- - - -
## GET alive?
Tests if the service is alive.
Used as a [Kubernetes](https://kubernetes.io/) liveness probe.
The runtime liveness probe to see if the service is alive.
- parameters
* none
- returns [(JSON-out)](#json-out)
* **true**
- example
```bash
$ curl --silent -X GET http://${IP_ADDRESS}:${PORT}/alive?
$ curl --silent -X GET https://${IP_ADDRESS}:${PORT}/alive?

{"alive?":true}
```

- - - -
## GET ready?
Tests if the service is ready to handle requests.
Used as a [Kubernetes](https://kubernetes.io/) readiness probe.
The runtime readiness probe to see if the service is ready to handle requests.
- parameters
* none
- returns [(JSON-out)](#json-out)
* **true** if the service is ready
* **false** if the service is not ready
- example
```bash
$ curl --silent -X GET http://${IP_ADDRESS}:${PORT}/ready?
$ curl --silent -X GET https://${IP_ADDRESS}:${PORT}/ready?

{"ready?":false}
```
Expand All @@ -39,30 +37,45 @@ The git commit sha used to create the Docker image.
* the 40 character commit sha string.
- example
```bash
$ curl --silent -X GET http://${IP_ADDRESS}:${PORT}/sha
$ curl --silent -X GET https://${IP_ADDRESS}:${PORT}/sha

{"sha":"41d7e6068ab75716e4c7b9262a3a44323b4d1448"}
```

- - - -
## GET base-image
The base-image used in the Dockerfile's FROM statement.
- parameters
* none
- result
* the name of the base image.
- example
```bash
$ curl --fail --silent --request GET https://${DOMAIN}:${PORT}/base_image
```
```bash
{"base_image":"cyberdojo/sinatra-base:edb2887"}
```


- - - -
## JSON in
- All methods pass any arguments as a json hash in the http request body.
* If there are no arguments you can use `''` (which is the default
for `curl --data`) instead of `'{}'`.
* If there are no arguments you can use `''` (which is the default for `curl --data`) instead of `'{}'`.

- - - -
## JSON out
- All methods return a json hash in the http response body.
* If the method completes, a string key equals the method's name. eg
```bash
$ curl --silent -X GET http://${IP_ADDRESS}:${PORT}/ready?
$ curl --silent -X GET https://${IP_ADDRESS}:${PORT}/ready?

{"ready?":true}
```
* If the method raises an exception, a string key equals `"exception"`, with
a json-hash as its value. eg
```bash
$ curl --silent -X POST http://${IP_ADDRESS}:${PORT}/group_create_custom | jq
$ curl --silent -X POST https://${IP_ADDRESS}:${PORT}/group_create_custom | jq
{
"exception": {
Expand Down

0 comments on commit f266b06

Please sign in to comment.