Add dismiss action

This commit is contained in:
Alexey Igrychev
2020-05-27 00:17:25 +01:00
parent 1d91fd29fd
commit 9dcc6e256f
6 changed files with 44566 additions and 1 deletions

View File

@@ -8,6 +8,7 @@ This action set allows you to organize CI/CD with GitHub Actions and [werf](http
- [flant/werf-actions/converge](https://github.com/flant/werf-actions/tree/master/converge) - [flant/werf-actions/converge](https://github.com/flant/werf-actions/tree/master/converge)
- [flant/werf-actions/build-and-publish](https://github.com/flant/werf-actions/tree/master/build-and-publish) - [flant/werf-actions/build-and-publish](https://github.com/flant/werf-actions/tree/master/build-and-publish)
- [flant/werf-actions/deploy](https://github.com/flant/werf-actions/tree/master/deploy) - [flant/werf-actions/deploy](https://github.com/flant/werf-actions/tree/master/deploy)
- [flant/werf-actions/dismiss](https://github.com/flant/werf-actions/tree/master/dismiss)
- [flant/werf-actions/cleanup](https://github.com/flant/werf-actions/tree/master/cleanup) - [flant/werf-actions/cleanup](https://github.com/flant/werf-actions/tree/master/cleanup)
Each action combines all the necessary steps in itself and logic may be divided into __environment setup__ and launching the corresponding command. Each action combines all the necessary steps in itself and logic may be divided into __environment setup__ and launching the corresponding command.
@@ -130,6 +131,24 @@ deploy:
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }} kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
``` ```
### dismiss
```yaml
dismiss:
name: Dismiss
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Dismiss
uses: flant/werf-actions/dismiss@v1
with:
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
env: production
```
### cleanup ### cleanup
```yaml ```yaml

108
dismiss/README.md Normal file
View File

@@ -0,0 +1,108 @@
<p align="center">
<img src="https://github.com/flant/werf/raw/master/docs/images/werf-logo.svg?sanitize=true" style="max-height:100%;" height="175">
</p>
___
The action combines all the necessary steps in itself and logic may be divided into environment setup and launching `werf dismiss`.
## Action in Details
### werf binary setup
By default, all actions setup actual werf version for [1.1 stable channel](https://werf.io/releases.html) (more details about channels, werf release cycle and compatibility promise [here](https://github.com/flant/werf#backward-compatibility-promise)).
Using `group` and `channel` inputs the user can switch the release channel.
> This is recommended approach to be up-to-date and to use actual werf version without changing configurations
```yaml
- uses: flant/werf-actions/converge@v1
with:
group: 1.1
channel: alpha
```
Withal, it is not necessary to work within release channels, and the user might specify certain werf version with `version` input.
```yaml
- uses: flant/werf-actions/converge@v1
with:
version: v1.1.16
```
### kubeconfig setup (*optional*)
The _kubeconfig_ may be used for deployment, cleanup, distributed locks and caches. Thus, the configuration should be added before step with the action or passed as base64 encoded data with `kube-config-base64-data` input:
* Prepare _kubeconfig_ (e.g. `cat ~/.kube/config | base64`) and save in GitHub Project Secrets (e.g. with name `KUBE_CONFIG_BASE64_DATA`).
* Pass secret with `kube-config-base64-data` input:
```yaml
- uses: flant/werf-actions/converge@v1
with:
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
```
### werf ci-env
This command performs _docker login_ using `github-token`, sets up predefined variables based on GitHub Workflow context.
**Note** that `github-token` is optional in this action, and the input is there in case you need to use a non-default token.
By default, action will use the token provided to your workflow.
## Working with werf options
Any werf option can be defined with environment variables:
```yaml
- uses: flant/werf-actions/converge@v1
with:
env: production
env:
WERF_LOG_VERBOSE: "on"
```
## Inputs
```yaml
group:
description: 'The MAJOR.MINOR version'
default: '1.1'
required: false
channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable'
required: false
version:
description: 'The certain version'
required: false
env:
description: 'Specific deployment environment'
required: true
github-token:
description: 'The GitHub token used to login and to interact with Docker Github Packages'
default: ${{ github.token }}
required: false
kube-config-base64-data:
description: 'Base64 encoded kubeconfig data used for deployment, cleanup and distributed locks'
required: false
```
## Example
```yaml
dismiss:
name: Dismiss
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Dismiss
uses: flant/werf-actions/dismiss@v1
with:
kube-config-base64-data: ${{ secrets.KUBE_CONFIG_BASE64_DATA }}
env: production
```

31
dismiss/action.yml Normal file
View File

@@ -0,0 +1,31 @@
name: werf dismiss
author: 'Flant'
description: 'Prepare the environment and perform dismiss with werf'
branding:
color: blue
icon: anchor
inputs:
group:
description: 'The MAJOR.MINOR version'
default: '1.1'
required: false
channel:
description: 'The one of the following channel: alpha, beta, ea, stable, rock-solid'
default: 'stable'
required: false
version:
description: 'The certain version'
required: false
env:
description: 'Specific deployment environment'
required: true
github-token:
description: 'The GitHub token used to login and to interact with Docker Github Packages'
default: ${{ github.token }}
required: false
kube-config-base64-data:
description: 'Base64 encoded kubeconfig data used for deployment, cleanup and distributed locks'
required: false
runs:
using: 'node12'
main: 'index.js'

44372
dismiss/index.js Normal file

File diff suppressed because one or more lines are too long

View File

@@ -1,3 +1,3 @@
#!/bin/bash -e #!/bin/bash -e
for pkg in build-and-publish cleanup converge deploy install; do ncc build src/$pkg.ts -o $pkg; done for pkg in build-and-publish cleanup converge deploy dismiss install; do ncc build src/$pkg.ts -o $pkg; done

35
src/dismiss.ts Normal file
View File

@@ -0,0 +1,35 @@
import * as core from '@actions/core'
import {Manager} from './manager'
import {
ProcessGitHubContext,
SetupKubeConfig,
ValidateWerfVersion
} from './common'
async function run(): Promise<void> {
try {
ProcessGitHubContext()
const kubeConfigBase64Data = core.getInput('kube-config-base64-data')
if (kubeConfigBase64Data !== '') {
SetupKubeConfig(kubeConfigBase64Data)
}
const m = new Manager()
await m.Install()
const versionOutput = await m.GetOutput(['version'])
ValidateWerfVersion(versionOutput)
process.env.GITHUB_TOKEN =
process.env.GITHUB_TOKEN || core.getInput('github-token')
await m.PerformCIEnv()
process.env.WERF_ENV = core.getInput('env')
await m.Exec(['dismiss'])
} catch (error) {
core.setFailed(error.message)
}
}
run()