Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 0 additions & 26 deletions .github/actions/setup-kraftkit/action.yaml

This file was deleted.

47 changes: 47 additions & 0 deletions .github/actions/setup-unikraft/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: setup-unikraft

description: |
Install the Unikraft CLI and configure a profile for Unikraft Cloud.

inputs:
token:
required: true
description: Unikraft Cloud API token.
metro:
required: true
description: Unikraft Cloud metro endpoint (e.g. https://api.dal2.unikraft.cloud).
profile:
required: false
default: oss-www
description: Name of the CLI profile to configure and activate.
version:
required: false
default: latest
description: Unikraft CLI version to install.

runs:
using: composite
steps:
- name: Install Unikraft CLI
uses: unikraft/setup-action@v1
with:
version: ${{ inputs.version }}

- name: Configure profile
shell: bash
env:
UKC_TOKEN: ${{ inputs.token }}
UKC_METRO: ${{ inputs.metro }}
PROFILE: ${{ inputs.profile }}
run: |
mkdir -p "$HOME/.config/unikraft"
cat > "$HOME/.config/unikraft/config.yaml" << EOF
profile: ${PROFILE}
profiles:
${PROFILE}:
type: cloud
token: ${UKC_TOKEN}
metros:
- name: ${PROFILE}
endpoint: ${UKC_METRO}
EOF
62 changes: 26 additions & 36 deletions .github/actions/setup-www/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,14 @@ inputs:
domain:
required: false
description: The domain to use for the deployment.
metro:
required: false
description: Unikraft Cloud Metro.
default: http://api.dal2.unikraft.cloud/v1
memory:
required: false
description: Set the memory size.
default: 1536Mi
args:
required: false
description: Optional arguments you pass to kraft cloud deploy.
default: 1536M
port:
required: false
description: The port the service listens on.
default: "3000"
log-level:
required: false
default: error
description: Set the logging level.

outputs:
domain:
Expand All @@ -58,39 +47,39 @@ runs:
set -e;

# Create the service if it does not exist.
_SVC=$(kraft cloud --metro "${{ inputs.metro }}" service get "${{ inputs.name }}" -o raw | jq -r '.data.service_groups[].error')
if [[ "${_SVC}" == "8" ]]; then
if [[ "${{ inputs.domain }}" == "" ]]; then
kraft cloud --metro "${{ inputs.metro }}" service create \
--subdomain "${{ inputs.name }}" \
--name "${{ inputs.name }}" \
"443:${{ inputs.port }}" \
;
else
kraft cloud --metro "${{ inputs.metro }}" service create \
--domain "${{ inputs.domain }}" \
--name "${{ inputs.name }}" \
"443:${{ inputs.port }}" \
;
fi
if ! unikraft service get "${{ inputs.name }}" -o quiet 2>/dev/null; then
unikraft service create \
--domains "${{ inputs.domain || inputs.name }}" \
--name "${{ inputs.name }}" \
--services "443:${{ inputs.port }}/http+tls" \
;
fi

# Save the generated domain as an output variable
echo "domain=$(kraft cloud --metro ${{ inputs.metro }} service get ${{ inputs.name }} -o raw | jq -r '.data.service_groups[0].domains[0].fqdn')" >> $GITHUB_OUTPUT
echo "domain=$(unikraft service get ${{ inputs.name }} -o json | jq -r '.[0].domains[0].fqdn')" >> $GITHUB_OUTPUT

- name: Deploy
id: deploy
shell: bash
run: |
kraft cloud deploy \
--rollout remove \
--rollout-qualifier all \
unikraft build \
--output "oci://internal/${{ inputs.name }}:latest" \
.;

# Remove any existing instance(s) on this service before running the
# new one, so the service always ends up with just the latest build.
unikraft instance delete \
--filter "service.name==${{ inputs.name }}" \
--force \
2>/dev/null || true;

unikraft run \
--autostart \
--restart always \
--memory "${{ inputs.memory }}" \
--service "${{ inputs.name }}" \
--image "${{ inputs.name }}" \
--as kraftfile-runtime \
${{ inputs.args }} \
.;
--image "internal/${{ inputs.name }}:latest" \
;

- name: Test liveliness
id: liveliness
Expand All @@ -104,7 +93,8 @@ runs:
if: ${{ steps.liveliness.outcome == 'failure' }}
shell: bash
run: |
kraft cloud service logs "${{ inputs.name }}"
_INST=$(unikraft service get "${{ inputs.name }}" -o json | jq -r '.[0].instances[0].name')
unikraft instance logs "${_INST}"
exit 1

- name: Update Deployment
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,7 @@ on:
env:
UKC_TOKEN: ${{ secrets.UKC_TOKEN }}
UKC_METRO: ${{ secrets.UKC_METRO }}
KRAFTKIT_LOG_LEVEL: debug
KRAFTKIT_NO_CHECK_UPDATES: "true"
UNIKRAFT_LOG_LEVEL: debug

permissions:
deployments: write
Expand All @@ -38,8 +37,11 @@ jobs:
exit 1
fi

- name: Setup KraftKit
uses: ./.github/actions/setup-kraftkit
- name: Setup Unikraft CLI
uses: ./.github/actions/setup-unikraft
with:
token: ${{ secrets.UKC_TOKEN }}
metro: ${{ secrets.UKC_METRO }}

- name: Setup OSS docs website
id: www
Expand All @@ -49,8 +51,6 @@ jobs:
environment: main
name: oss-www
domain: unikraft.org
metro: ${{ secrets.UKC_METRO }}
log-level: trace

- uses: chrnorm/deployment-action@v2
name: Create GitHub deployment
Expand Down
Loading