Skip to content

Commit a3b800d

Browse files
chore: create ci release (efb34d6)
0 parents  commit a3b800d

19 files changed

Lines changed: 9121 additions & 0 deletions

.eslintrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "tale"
3+
}

.github/workflows/deploy.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Deploy Action
2+
3+
on:
4+
push:
5+
tags:
6+
- '*'
7+
- '!v1'
8+
9+
jobs:
10+
deploy:
11+
name: Deploy
12+
runs-on: ubuntu-latest
13+
steps:
14+
- name: Checkout Repository
15+
uses: actions/checkout@v3
16+
- name: Build latest dist/ folder
17+
run: |
18+
npm ci
19+
npm run build
20+
- name: Upload dist/ folder
21+
run: |
22+
git config --global user.email "<41898282+github-actions[bot]@users.noreply.github.com>"
23+
git config --global user.name "github-actions[bot]"
24+
git checkout --orphan deploy
25+
git add -f dist README.md LICENSE action.yaml
26+
git commit -m "chore: create ci release ($GITHUB_SHA)"
27+
git tag --force v1
28+
git tag --force $GITHUB_REF_NAME
29+
git push -f --tags origin deploy

.github/workflows/test.yaml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Test Action
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
7+
jobs:
8+
build:
9+
name: Build
10+
runs-on: ubuntu-latest
11+
steps:
12+
- name: Checkout Repository
13+
uses: actions/checkout@v3
14+
- name: Build latest dist/ folder
15+
run: |
16+
npm ci
17+
npm run build
18+
- name: Upload dist/ folder
19+
run: |
20+
git config --global user.email "<41898282+github-actions[bot]@users.noreply.github.com>"
21+
git config --global user.name "github-actions[bot]"
22+
git checkout --orphan ci
23+
git add -f dist README.md LICENSE action.yaml
24+
git commit -m "chore: create ci release ($GITHUB_SHA)"
25+
git push -f origin ci
26+
test:
27+
name: Test
28+
runs-on: ubuntu-latest
29+
needs: build
30+
steps:
31+
- name: Setup tale/kubectl-action
32+
uses: tale/kubectl-action@ci
33+
with:
34+
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
35+
- name: Test the output of `kubectl cluster-info`
36+
run: kubectl cluster-info

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules/
2+
dist/

.vscode/settings.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"editor.codeActionsOnSave": {
3+
"source.fixAll.eslint": true
4+
}
5+
}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2023 Aarnav Tale
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.

README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# kubectl-action
2+
3+
GitHub Action to manage a K8s (Kubernetes) cluster using kubectl.
4+
5+
## Usage
6+
7+
To use this action, add the following step to your GitHub Action workflow:
8+
9+
```yaml
10+
- uses: tale/kubectl-action@v1
11+
with:
12+
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
13+
```
14+
15+
Keep in mind that the action expects a base64 encoded string of your Kubernetes configuration. The simplest way to do that is to run `cat $HOME/.kube/config | base64` and save that output as an action secret. It's additionally possible to generate a config file using the `aws` CLI for EKS or any other tools with other cloud providers.
16+
17+
It's also possible to specify the version of the [kubectl](https://kubernetes.io/docs/reference/kubectl/) CLI to use. The current default release used by this action is the latest version.
18+
19+
```yaml
20+
- uses: tale/kubectl-action@v1
21+
with:
22+
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
23+
kubectl-version: v1.22.0
24+
```
25+
26+
Once you've completed this setup, you have direct access to the `kubectl` binary and command in the rest of your actions. Here's a full example to give you some inspiration:
27+
28+
```yaml
29+
name: Kubectl Action
30+
31+
on:
32+
workflow_dispatch:
33+
34+
jobs:
35+
build:
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: tale/kubectl-action@v1
39+
with:
40+
base64-kube-config: ${{ secrets.KUBE_CONFIG }}
41+
- run: kubectl get pods
42+
```
43+
44+
Here's an example using AWS EKS:
45+
46+
```yaml
47+
name: Kubectl Action
48+
49+
on:
50+
workflow_dispatch:
51+
52+
jobs:
53+
build:
54+
runs-on: ubuntu-latest
55+
steps:
56+
- name: Configure AWS Credentials
57+
uses: aws-actions/configure-aws-credentials@v4
58+
with:
59+
role-to-assume: arn:aws:iam::123456789100:role/my-github-actions-role
60+
aws-region: us-east-2
61+
- name: Generate kubeconfig
62+
run: echo "EKS_CREDS=$(aws eks update-kubeconfig --region us-east-2 --name my-cluster --dry-run | base64) >> $GITHUB_ENV
63+
- uses: tale/kubectl-action@v1
64+
with:
65+
base64-kube-config: ${{ env.EKS_CREDS }}
66+
- run: kubectl get pods
67+
```

action.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
name: Kubernetes CLI (kubectl)
2+
description: GitHub Action to manage a K8s cluster using kubectl
3+
author: Aarnav Tale <aarnav@tale.me>
4+
branding:
5+
icon: terminal
6+
color: blue
7+
inputs:
8+
kubectl-version:
9+
description: Version of the kubectl CLI to use
10+
required: false
11+
default: latest
12+
base64-kube-config:
13+
description: A base64 encoded reference to your authorization file (~/.kube/config)
14+
required: true
15+
runs:
16+
using: node20
17+
main: dist/index.js
18+
post: dist/index.js

dist/index.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/index.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)