Skip to content

Commit

Permalink
feat: initial import
Browse files Browse the repository at this point in the history
  • Loading branch information
thesharp committed Oct 1, 2023
0 parents commit c045f40
Show file tree
Hide file tree
Showing 3 changed files with 103 additions and 0 deletions.
7 changes: 7 additions & 0 deletions LICENSE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Copyright 2023 Ilya Otyutskiy

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36 changes: 36 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
# simple-k8s-deploy action

This action deploys to a locally available Kubernetes cluster (you have to have a correct `ServiceAccount` attached to your runner pods). A kubectl and yq would be downloaded before conducting a deployment.

## Inputs

## `kubectl_version`

kubectl binary version. Default `"1.28.2"`.

## `manifest_filepath`

Path to a Kubernetes deployment manifest. Default `"kubernetes/deployment.yaml"`.

## `container_name`

**Required** Container name that would have it's image overwritten inside the deployment manifest.

## `image_name`

**Required** Image name that would be overwritten inside the deployment manifest.

## Outputs

## `kubectl-apply`

Result of kubectl apply.

## Example usage

```yaml
uses: thesharp/simple-k8s-deploy@v1
with:
container_name: "application"
image_name: "ghcr.io/user/application:1.55"
```
60 changes: 60 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: "Simple Kubernetes deploy"
description: "Deploy manifest into a local Kubernetes cluster (available through kubectl)"
author: "thesharp"

inputs:
kubectl_version:
description: |
kubectl binary version.
Default "1.28.2"
default: "1.28.2"
required: false
manifest_filepath:
description: |
Path to a Kubernetes deployment manifest.
Default "kubernetes/deployment.yaml"
default: "kubernetes/deployment.yaml"
required: false
container_name:
description: |
Container name that would have it's image overwritten inside the deployment manifest.
required: true
image_name:
description: |
Image name that would be overwritten inside the deployment manifest.
required: true

runs:
using: "composite"
steps:
- name: Install kubectl
shell: bash
run: sudo curl -L "https://dl.k8s.io/release/v${{ inputs.kubectl_version }}/bin/linux/amd64/kubectl" -o /usr/local/bin/kubectl && sudo chmod 755 /usr/local/bin/kubectl

- name: Install yq
shell: bash
run: sudo curl -L "https://github.com/mikefarah/yq/releases/latest/download/yq_linux_amd64" -o /usr/local/bin/yq && sudo chmod 755 /usr/local/bin/yq

- name: Replace image inside the manifest
shell: bash
run: yq -i '(.spec.template.spec.containers[] | select (.name == "${{ inputs.container_name }}").image) = "${{ inputs.image_name }}"' ${{ inputs.manifest_filepath }}

- name: Deploy
shell: bash
id: kubectl-apply
run: echo "deployment=$(kubectl apply -f ${{ inputs.manifest_filepath }})" >> $GITHUB_OUTPUT

- name: Generate summary
shell: bash
run: |
echo "### Deployment status :rocket:" >> $GITHUB_STEP_SUMMARY
echo "```${{ steps.kubectl-apply.outputs.deployment }}```" >> $GITHUB_STEP_SUMMARY
outputs:
kubectl-apply:
description: "Result of kubectl apply"
value: "deployment"

branding:
icon: "truck"
color: "blue"

0 comments on commit c045f40

Please sign in to comment.