Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

github-action: undeploy my kibana #2595

Merged
merged 5 commits into from
May 6, 2024
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .github/actions/undeploy-my-kibana/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
## About

GitHub Action to undeploy my kibana process

* [Usage](#usage)
* [Configuration](#configuration)
* [Customizing](#customizing)
* [inputs](#inputs)

## Usage

### Configuration

Given the CI GitHub action:

```yaml
---
name: Destroy cluster using the oblt-cli
on:
pull_request:
types: [closed]
jobs:
deploy-my-kibana:
runs-on: ubuntu-latest
steps:
- uses: elastic/apm-pipeline-library/.github/actions/undeploy-my-kibana@current
with:
vault-url: ${{ secrets.OBLT_VAULT_ADDR }}
vault-role-id: ${{ secrets.OBLT_VAULT_ROLE_ID }}
vault-secret-id: ${{ secrets.OBLT_VAULT_SECRET_ID }}
```

## Customizing

### inputs

Following inputs can be used as `step.with` keys

| Name | Type | Default | Description |
|-------------------|---------|----------------------------------------|------------------------------------|
| `pull-request` | String | `${{ github.event.pull_request.number }}` | The GitHub Pull Request ID. |
| `user` | String | `${{ github.event.pull_request.head.repo.owner.login }}` | The GitHub user avatar |
| `repository` | String | `${{ github.repository }}` | The GitHub repository, ORG/REPO. |
| `vault-role-id` | String | | The Vault role id. |
| `vault-secret-id` | String | | The Vault secret id. |
| `vault-url` | String | | The Vault URL to connect to. |

### outputs

| Name | Type | Description |
|-------------------|---------| ------------------------------------------|
| `issue` | String | The GitHub issue URL with the deployment. |
66 changes: 66 additions & 0 deletions .github/actions/undeploy-my-kibana/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
name: 'Undeploy My Kibana'
description: 'GitHub Action to undeploy my kibana given the Pull Request'
inputs:
vault-url:
description: 'Vault URL'
required: true
vault-role-id:
description: 'Vault role ID'
required: true
vault-secret-id:
description: 'Vault secret ID'
required: true
pull-request:
description: 'The GitHub Pull Request ID'
default: ${{ github.event.pull_request.number }}
repository:
description: 'The GitHub repository'
default: ${{ github.repository }}
user:
description: 'The GitHub PR onwer'
default: ${{ github.event.pull_request.head.repo.owner.login }}
v1v marked this conversation as resolved.
Show resolved Hide resolved
runs:
using: "composite"
steps:
- uses: elastic/apm-pipeline-library/.github/actions/github-token@current
with:
url: ${{ inputs.vault-url }}
roleId: ${{ inputs.vault-role-id }}
secretId: ${{ inputs.vault-secret-id }}

- name: Is an Elastician comment?
id: is_elastic_member
uses: elastic/apm-pipeline-library/.github/actions/is-member-elastic-org@current
with:
username: ${{ inputs.user }}
token: ${{ env.GITHUB_TOKEN }}
v1v marked this conversation as resolved.
Show resolved Hide resolved

- name: Create github issue body
if: contains(steps.is_elastic_member.outputs.result, 'true')
run: |-
cat <<EOT >> .body-content
### Kibana branch

${{ inputs.pull-request }}
v1v marked this conversation as resolved.
Show resolved Hide resolved

### Further details

Caused by @${{ inputs.user }} in https://github.com/elastic/kibana/pull/${{ inputs.pull-request }}
v1v marked this conversation as resolved.
Show resolved Hide resolved
EOT
shell: bash

- name: Create github issue for the undeploy-my-kibana
if: contains(steps.is_elastic_member.outputs.result, 'true')
run: |
gh issue \
create \
--label 'destroy-custom-kibana-serverless' \
--title "[Undeploy Kibana] for user ${{ inputs.user }} with PR kibana@pr-${{ inputs.pull-request }}" \
v1v marked this conversation as resolved.
Show resolved Hide resolved
--body-file .body-content \
--repo elastic/observability-test-environments | tee .issue
echo "ISSUE=$(cat .issue)" >> $GITHUB_ENV
echo "issue=$ISSUE" >> "$GITHUB_OUTPUT"
env:
GH_TOKEN: ${{ env.GITHUB_TOKEN }}
v1v marked this conversation as resolved.
Show resolved Hide resolved
shell: bash
Loading