Skip to content

Commit

Permalink
feature: github action using starshipjs (#27)
Browse files Browse the repository at this point in the history
  • Loading branch information
Anmol1696 authored Jun 12, 2024
1 parent 93cca63 commit 00923e7
Show file tree
Hide file tree
Showing 8 changed files with 62 additions and 274 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ jobs:
- uses: ./
id: starship
with:
port-forward: true
name: test-with-values
values: config.yaml

Expand Down Expand Up @@ -130,7 +129,6 @@ jobs:
- uses: ./
id: starship
with:
port-forward: true
name: test-kubeconfig
kubeconfig: ${{ steps.kubeconfig.outputs.content }}
values: config.yaml
Expand All @@ -149,7 +147,7 @@ jobs:
NAMESPACE: ${{ steps.starship.outputs.namespace }}
NAME: ${{ steps.starship.outputs.name }}

test-with-no-portforward:
test-with-no-ports:
runs-on: ubuntu-latest
steps:

Expand All @@ -170,7 +168,6 @@ jobs:
- uses: ./
id: starship
with:
port-forward: false
name: test-no-portforward
values: config.yaml

Expand Down
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,8 @@ bin-release/
# Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties`
# should NOT be excluded as they contain compiler settings and other important
# information for Eclipse / Flash Builder.
**/node_modules/
**/.DS_Store
**/dist
**/yarn-error.log
lerna-debug.log
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ For more information, reference the GitHub Help Documentation for [Creating a wo
For more information on inputs, see the [API Documentation](https://developer.github.com/v3/repos/releases/#input)

- `values`: Required, config for helm chart for starship devnet inputs
- `port-forward`: Optional, toggle to perform local port-forwarding, based on the `values.yaml` (default: `false`)
- `version`: Optional, version of devnet helm chart from starship (default: `0.2.3`)
- `cli-version`: Optional, version of @starship-ci/cli to use (default: `2.4.0`)
- `kubeconfig`: Optional, Kubeconfig for remote cluster, if set, will be used instead of creating local kind cluster
- `version`: Optional, version of devnet chart from starship (default: `0.2.3`)
- `namespace`: Optional, Kubernetes namespace to which helm charts will be deployed. If not found, namespace will be created. (default: `ci-${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}`)
- `repo`: Optional, Helm repo to fetch the chart from (default: https://cosmology-tech.github.io/starship)
- `name`: Optional, Release name for the helm chart deployment (default: `starship-devnet`)
- `namespace`: Optional, Kubernetes namespace to which helm charts will be deployed. If not found, namespace will be created. (default: `ci-${{ github.repository }}-${{ github.workflow }}-${{ github.ref }}`)
- `chart`: Optional, Name of the help chart to use. Recommended: use default (default: `starship/devnet`)

### Outputs
Expand Down
74 changes: 41 additions & 33 deletions action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,18 @@ inputs:
values:
description: "Values yaml raw data of filename for helm that define the topology for the devnet"
required: true
port-forward:
description: "Flag weather to perform port forwarding as defined in the values file to local ports (default: true)"
version:
description: "Version of devnet chart (default: v0.2.3)"
required: false
default: "v0.2.3"
cli-version:
description: "Version of @starship-ci/cli to use: default: 2.3.0"
required: false
default: "true"
default: "2.4.0"
kubeconfig:
description: "Kubeconfig file for remote cluster, if set, will be used instead of creating kind cluster"
required: false
default: ""
version:
description: "Version of devnet chart (default: 0.1.45)"
required: false
default: "0.2.3"
chart:
description: "Name of the help chart to use. Recommended: use default (default: starship/devnet)"
required: false
Expand All @@ -36,10 +36,6 @@ inputs:
description: "Kubernetes namespace to deploy helm charts on (default: ci-{github.repository}-{github.workflow}-{github.ref} )"
required: false
default: ""
timeout:
description: "Timeout for helm install (default: 10m)"
required: false
default: "10m"

outputs:
namespace:
Expand All @@ -53,12 +49,11 @@ runs:
using: composite
steps:

- name: Install dependencies
run: |
sudo apt-get install -y make sed wget tar jq
sudo wget https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
shell: bash
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20.x"
cache: "yarn"

- name: Setup helm
uses: azure/setup-helm@v3
Expand Down Expand Up @@ -112,12 +107,25 @@ runs:
env:
INPUT_NAMESPACE: ${{ inputs.namespace }}

- name: Create namespace if nonexistent
run: |
kubectl create namespace ${{ steps.set-namespace.outputs.namespace }} || true
shell: bash

- name: Setup starshipjs client
run: |
yarn global add @starship-ci/cli@${{ inputs.cli-version }}
starship --version
shell: bash

- name: Setup starship helm repo
run: |
helm version
helm repo add starship ${{ inputs.repo }}
helm repo update
helm search repo starship/devnet
starship setup \
--helmName ${{ inputs.name }} \
--helmVersion ${{ inputs.version }} \
--helmFile $GITHUB_WORKSPACE/${{ inputs.name }}-values.yaml \
--helmNamespace ${{ steps.set-namespace.outputs.namespace }} \
--helmChart ${{ inputs.chart }}
shell: bash

- name: Helm install
Expand All @@ -126,7 +134,12 @@ runs:
run: |
helm delete ${{ inputs.name }} --debug --namespace ${{ steps.set-namespace.outputs.namespace }} --wait || true
sleep 5
${{ github.action_path }}/install.sh --config ${{ inputs.values }} --name ${{ inputs.name }} --chart ${{ inputs.chart }} --version ${{ inputs.version }} --namespace ${{ steps.set-namespace.outputs.namespace }} --timeout ${{ inputs.timeout }}
starship start \
--helmName ${{ inputs.name }} \
--helmVersion ${{ inputs.version }} \
--helmFile $GITHUB_WORKSPACE/${{ inputs.name }}-values.yaml \
--helmNamespace ${{ steps.set-namespace.outputs.namespace }} \
--helmChart ${{ inputs.chart }}
shell: bash

- name: Logs
Expand All @@ -152,15 +165,10 @@ runs:
helm delete ${{ inputs.name }} --debug --namespace ${{ steps.set-namespace.outputs.namespace }} --wait || true
sleep 5
kubectl get pods --namespace ${{ steps.set-namespace.outputs.namespace }}
${{ github.action_path }}/install.sh --config ${{ inputs.name }}-values.yaml --name ${{ inputs.name }} --chart ${{ inputs.chart }} --version ${{ inputs.version }} --namespace ${{ steps.set-namespace.outputs.namespace }} --timeout ${{ inputs.timeout }}
shell: bash

- name: Port forward
if: ${{ inputs.port-forward == 'true' }}
run: |
kubectl version
${{ github.action_path }}/port-forward.sh --config=$VALUES_FILE --namespace=$NAMESPACE
starship start \
--helmName ${{ inputs.name }} \
--helmVersion ${{ inputs.version }} \
--helmFile $GITHUB_WORKSPACE/${{ inputs.name }}-values.yaml \
--helmNamespace ${{ steps.set-namespace.outputs.namespace }} \
--helmChart ${{ inputs.chart }}
shell: bash
env:
VALUES_FILE: ${{ inputs.name }}-values.yaml
NAMESPACE: ${{ steps.set-namespace.outputs.namespace }}
99 changes: 0 additions & 99 deletions install.sh

This file was deleted.

8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "starship-action",
"version": "1.0.0",
"main": "index.js",
"repository": "git@github.com:cosmology-tech/starship-action.git",
"author": "Anmol1696 <anmol1696@gmail.com>",
"license": "MIT"
}
Loading

0 comments on commit 00923e7

Please sign in to comment.