Skip to content

Commit

Permalink
Use inputs instead of env vars for GitHub action
Browse files Browse the repository at this point in the history
  • Loading branch information
th0th committed Jan 26, 2023
1 parent f7b9f23 commit 249b302
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 24 deletions.
49 changes: 35 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,53 @@
`rancher-redeploy-workload` is a docker image that redeploys kubernetes workloads using Rancher's API.
`rancher-redeploy-workload` is a GitHub action (and docker image) that redeploys kubernetes workloads using Rancher's API.

## Running
## Usage

![Hint](hint.png)

### Running as a GitHub action

```yaml
- name: Update rancher deployment
uses: th0th/[email protected]
env:
RANCHER_BEARER_TOKEN: ${{ secrets.RANCHER_BEARER_TOKEN }}
RANCHER_CLUSTER_ID: 'c-qxyky'
RANCHER_NAMESPACE: 'namespace'
RANCHER_PROJECT_ID: 'p-hm2z1'
RANCHER_URL: 'https://rancher.aperturescience.tld'
RANCHER_WORKLOADS: 'wheatley1,wheatley2'
uses: th0th/[email protected]
with:
debug: 'false'
disable_output: 'false'
rancher_bearer_token: ${{ secrets.RANCHER_BEARER_TOKEN }}
rancher_cluster_id: 'c-qxyky'
rancher_namespace: 'namespace'
rancher_project_id: 'p-hm2z1'
rancher_url: 'https://rancher.aperturescience.tld'
rancher_workloads: 'wheatley1,wheatley2'
```
#### Inputs
| Variable | Required | Default value | Description |
|----------------------|:--------:|---------------|------------------------------------------------------------------------------------------------------|
| debug | | 'false' | Debug flag (useful when something fails) |
| disable_output | | 'false' | Disables outputting to stdout (useful if the logs are public, but you don't want to expose anything) |
| rancher_bearer_token | ✔ | | Bearer token used for authenticating on Rancher |
| rancher_cluster_id | ✔ | | Cluster's id on Rancher |
| rancher_namespace | ✔ | | Kubernetes namespace of the deployment to be updated |
| rancher_project_id | ✔ | | Project's id on Rancher |
| rancher_url | ✔ | | Base URL of the Rancher |
| rancher_workloads | ✔ | | Comma separated list of workloads to be updated (e.g. deployment1,deployment2) |
### Running as a docker container
```shell script
$ docker run --rm -it \
-e DEBUG="false" \
-e DISABLE_OUTPUT="false" \
-e RANCHER_BEARER_TOKEN="token-xgskl:n45p7tmd47t9lfzh7xl8rw6rvtrfzzxrtdr6qvjg27r4sjcxvzss7d" \
-e RANCHER_CLUSTER_ID="c-qxyky" \
-e RANCHER_NAMESPACE="namespace" \
-e RANCHER_PROJECT_ID="p-hm2z1" \
-e RANCHER_URL="https://rancher.aperturescience.tld" \
-e RANCHER_WORKLOADS="wheatley1,wheatley2" \
th0th/rancher-redeploy-workload:0.9.1
th0th/rancher-redeploy-workload:0.9.2
```

## Shameless plug

I am an indie hacker, and I am running two services that might be useful for your business. Check them out :)
Expand All @@ -38,17 +56,20 @@ I am an indie hacker, and I am running two services that might be useful for you

[<img alt="WebGazer" src="https://user-images.githubusercontent.com/698079/162474223-f7e819c4-4421-4715-b8a2-819583550036.png" width="256" />](https://www.webgazer.io/?utm_source=github&utm_campaign=rancher-redeploy-workload-readme)

[WebGazer](https://www.webgazer.io/?utm_source=github&utm_campaign=rancher-redeploy-workload-readme) is a monitoring service that checks your website, cron jobs, or scheduled tasks on a regular basis. It notifies
[WebGazer](https://www.webgazer.io/?utm_source=github&utm_campaign=rancher-redeploy-workload-readme) is a monitoring
service that checks your website, cron jobs, or scheduled tasks on a regular basis. It notifies
you with instant alerts in case of a problem. That way, you have peace of mind about the status of your service without
manually checking it.

### PoeticMetric

[<img alt="PoeticMetric" src="https://user-images.githubusercontent.com/698079/162474946-7c4565ba-5097-4a42-8821-d087e6f56a5d.png" width="256" />](https://www.poeticmetric.com/?utm_source=github&utm_campaign=rancher-redeploy-workload-readme)

[PoeticMetric](https://www.poeticmetric.com/?utm_source=github&utm_campaign=rancher-redeploy-workload-readme) is a privacy-first, regulation-compliant, blazingly fast analytics tool.
[PoeticMetric](https://www.poeticmetric.com/?utm_source=github&utm_campaign=rancher-redeploy-workload-readme) is a
privacy-first, regulation-compliant, blazingly fast analytics tool.

No cookies or personal data collection. So you don't have to worry about cookie banners or GDPR, CCPA, and PECR compliance.
No cookies or personal data collection. So you don't have to worry about cookie banners or GDPR, CCPA, and PECR
compliance.

## License

Expand Down
34 changes: 30 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,35 @@
name: Rancher redeploy workload
description: An action for redeploying Rancher workload(s)
author: Gokhan Sari
author: "Gokhan Sari"
branding:
icon: package
color: blue
description: "An action for redeploying Rancher workload(s)"
inputs:
debug:
description: "Debug flag"
disable_output:
description: "Disables outputting to stdout (useful if the logs are public, but you don't want to expose anything)"
rancher_bearer_token:
description: "Bearer token used for authenticating on Rancher"
rancher_cluster_id:
description: "Cluster's id on Rancher"
rancher_namespace:
description: "Kubernetes namespace of the deployment to be updated"
rancher_project_id:
description: "Project's id on Rancher"
rancher_url:
description: "Base URL of the Rancher"
rancher_workloads:
description: "Comma separated list of workloads to be updated (e.g. deployment1,deployment2)"
name: Rancher redeploy workload
runs:
env:
DEBUG: ${{ inputs.debug }}
DISABLE_OUTPUT: ${{ inputs.disable_output }}
RANCHER_BEARER_TOKEN: ${{ inputs.rancher_bearer_token }}
RANCHER_CLUSTER_ID: ${{ inputs.rancher_cluster_id }}
RANCHER_NAMESPACE: ${{ inputs.rancher_namespace }}
RANCHER_PROJECT_ID: ${{ inputs.rancher_project_id }}
RANCHER_URL: ${{ inputs.rancher_url }}
RANCHER_WORKLOADS: ${{ inputs.rancher_workloads }}
image: docker://th0th/rancher-redeploy-workload:0.9.2
using: docker
image: docker://th0th/rancher-redeploy-workload:0.9.1
Binary file modified hint.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
8 changes: 2 additions & 6 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,12 @@ func main() {
}
}

func p(a ...any) {
func pf(format string, a ...any) {
if !config.DisableOutput {
fmt.Print(a...)
fmt.Printf(format, a...)
}
}

func pf(format string, a ...any) {
fmt.Printf(format, a...)
}

func pln(a ...any) {
if !config.DisableOutput {
fmt.Println(a...)
Expand Down

0 comments on commit 249b302

Please sign in to comment.