-
Notifications
You must be signed in to change notification settings - Fork 0
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
feat: Initial Action #2
Merged
Changes from all commits
Commits
Show all changes
65 commits
Select commit
Hold shift + click to select a range
83f3420
wip
jsirianni 2364c0f
fix matrix
jsirianni 5438ff1
install cli
jsirianni c438e12
pull image
jsirianni d6a80d3
run bindplane in background
jsirianni 4d94905
arg syntax
jsirianni f3c5971
fix action name and uses field
jsirianni 5263a6e
switch to docker
jsirianni 5009f84
cURL
jsirianni a1b7617
put bindplane binary in path
jsirianni 74bfe20
fix args and add shellcheck to ci
jsirianni 79f74e1
remove missing function call
jsirianni bc582cd
Add debug resource get
jsirianni 7ce99fd
fix paths
jsirianni 5499a90
remove dir support
jsirianni baa2db7
fix resources for tests
jsirianni 72071cc
wait for bindplane to become ready
jsirianni 60f48ed
try setting bindplane host
jsirianni 9135e20
detect runner ip
jsirianni e0db5ac
detect internal ip
jsirianni d9f9f81
debug
jsirianni 9d59f6b
use first addr
jsirianni c3a45f3
exec into container
jsirianni 34311b8
test additional version
jsirianni 00e4c3f
try write back without commit
jsirianni 8366507
test write back
jsirianni 7bede5c
ci
jsirianni fbbcc9d
test write back
jsirianni 497c7de
test write back
jsirianni 6907d65
test write back
jsirianni 4044089
try write back
jsirianni 0e13d4b
add github auth
jsirianni de9b4a2
BindPlane OP Action: Update OTEL Configs
237fe44
clone repo
jsirianni d23dbd0
try again
jsirianni 45a79d4
latest
jsirianni a470a35
BindPlane OP Action: Update OTEL Configs
3170b22
shellcheck
jsirianni 51b1fce
prevent out of order commits
jsirianni 0b30f5c
BindPlane OP Action: Update OTEL Configs
a6fb59a
shellcheck
jsirianni 0c39ec2
return early if nothing to commit
jsirianni a62cc35
fix out path
jsirianni b2d7566
clone repo outside of orig context
jsirianni 1faa264
BindPlane OP Action: Update OTEL Configs
f4b0905
BindPlane OP Action: Update OTEL Configs
3a1b309
comment
jsirianni 05712c9
always run
jsirianni ff16905
fix workflow example
jsirianni 0f84df2
fix rm
jsirianni 7c53c33
skip apply if not on target branch
jsirianni 3a8a47e
update org
jsirianni 0be28d3
rename params
jsirianni 88f9324
fix bad rename
jsirianni 1c7ab46
enable bool for write back. Move branch check outside of write back b…
jsirianni 82f2f2e
some cleanup
jsirianni ceb9597
readme
jsirianni a25a5eb
badge
jsirianni a2c93e8
readme job name
jsirianni 5a051b9
grab pending version
jsirianni 2c3e0c5
add logging useful for debugging running action
jsirianni b91574a
remove unused files
jsirianni c6e5515
use latest instead of pending
jsirianni beb2524
cleanup zip output
jsirianni 39340e7
feat: Auto rollout (#4)
jsirianni File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,116 @@ | ||
name: CI | ||
on: | ||
pull_request: | ||
push: | ||
branches: | ||
- main | ||
- dev | ||
|
||
permissions: | ||
# Allow action to write raw configs back to the repository. | ||
contents: write | ||
|
||
# Run commits in order to prevent out of order write back commits. | ||
concurrency: | ||
group: ${{ github.head_ref || github.ref_name }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
shellcheck: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Install ShellCheck | ||
run: sudo apt-get install shellcheck | ||
|
||
- name: Run ShellCheck | ||
run: shellcheck -x -s bash entrypoint.sh | ||
|
||
test: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
# This matrix allows us to test multiple bindplane versions. | ||
# When writing back to the repo, we write to directories based | ||
# on the bindplane version. | ||
bindplane_versions: | ||
- 1.40.0 | ||
- 1.37.0 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Detect Runner IP | ||
run: echo "MAIN_IP=$(ip addr show | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | cut -f1 -d'/' | head -n 1)" >> $GITHUB_ENV | ||
|
||
- name: Print Runner IP | ||
run: echo $MAIN_IP | ||
|
||
- name: Pull BindPlane | ||
run: docker pull ghcr.io/observiq/bindplane-ee:${{ matrix.bindplane_versions }} | ||
|
||
- name: Start BindPlane | ||
run: | | ||
docker run \ | ||
-d \ | ||
--name bindplane \ | ||
-e BINDPLANE_USERNAME=admin \ | ||
-e BINDPLANE_PASSWORD=admin \ | ||
-e BINDPLANE_REMOTE_URL=http://${MAIN_IP}:3001 \ | ||
-e BINDPLANE_SESSION_SECRET=2c23c9d3-850f-4062-a5c8-3f9b814ae144 \ | ||
-e BINDPLANE_SECRET_KEY=8a5353f7-bbf4-4eea-846d-a6d54296b781 \ | ||
-e BINDPLANE_LOG_OUTPUT=stdout \ | ||
-e BINDPLANE_ACCEPT_EULA=true \ | ||
-p 3001:3001 \ | ||
ghcr.io/observiq/bindplane-ee:${{ matrix.bindplane_versions }} | ||
|
||
- name: Wait for BindPlane | ||
uses: nick-fields/retry@v2 | ||
with: | ||
timeout_minutes: 1 | ||
polling_interval_seconds: 5 | ||
max_attempts: 10 | ||
shell: bash | ||
command: docker exec bindplane /bindplane get agent | ||
|
||
- name: Run BindPlane Action | ||
# This should be replaced with a release action. | ||
# <organization>/<repository>@<tag> | ||
uses: ./ | ||
with: | ||
# These values are hardcode to match the test instance used by | ||
# this workflow. The instance does not persist. Consumers of | ||
# this action should always use secrets when passing in the remote | ||
# url, bindplane_username, bindplane_password or api key. | ||
# | ||
# Remote url will never be localhost when running this action. The action | ||
# executes in a container and localhost will always be the container's network | ||
# and not the network of the bindplane instance, even if that instance | ||
# is running within this runner. | ||
bindplane_remote_url: http://${{ env.MAIN_IP }}:3001 | ||
bindplane_username: admin | ||
bindplane_password: admin | ||
destination_path: test/resources/destinations/resource.yaml | ||
configuration_path: test/resources/configurations/resource.yaml | ||
configuration_output_dir: test/otel/${{ matrix.bindplane_versions }} | ||
target_branch: dev | ||
# Token should have contents: write permissions | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
enable_otel_config_write_back: true | ||
enable_auto_rollout: true | ||
|
||
- name: Get Resources | ||
if: always() | ||
run: | | ||
docker exec bindplane /bindplane get destinations | ||
docker exec bindplane /bindplane get configurations | ||
|
||
- name: Debug Container Logs | ||
if: always() | ||
run: docker logs bindplane |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Container image that runs your code | ||
FROM alpine:3.10 | ||
|
||
RUN apk add --no-cache bash curl git jq | ||
|
||
COPY --chmod=0755 entrypoint.sh /entrypoint.sh | ||
|
||
ENTRYPOINT ["/entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,95 @@ | ||
# bindplane-op-action | ||
[![CI](https://github.com/observIQ/bindplane-op-action/actions/workflows/ci.yml/badge.svg)](https://github.com/observIQ/bindplane-op-action/actions/workflows/ci.yml) | ||
|
||
# bindplane-op-action | ||
|
||
The BindPlane OP action can be used to deploy configurations to your BindPlane OP | ||
server. It also supports exporting the OpenTelemetry configurations back to the repository. | ||
|
||
## Configuration | ||
|
||
| Parameter | Default | Description | | ||
| :---------------------------- | :--------- | :------------------------------ | | ||
| bindplane_remote_url | required | The endpoint that will be used to connect to BindPalne OP. | | ||
| bindplane_api_key | | API key used to authenticate to BindPlane. Required when BindPlane multi account is enabled or when running on BindPlane Cloud | | ||
| bindplane_username | | Username used to authenticate to BindPlane. Not required if API key is set. | | ||
| bindplane_password | | Password used to authenticate to BindPlane. | ||
| target_branch | required | The branch that the action will use when applying resources to bindplane or when writing otel configs back to the repo. | | ||
| destination_path | | Path to the file which contains the BindPlane destination resources | | ||
| configuration_path | | Path to the file which contains the BindPlane configuration resources | | ||
| enable_otel_config_write_back | `false` | Whether or not the action should write the raw OpenTelemetry configurations back to the repository. | | ||
| configuration_output_dir | | When write back is enabled, this is the path that will be written to. | | ||
| token | | The Github token that will be used to write to the repo. Usually secrets.GITHUB_TOKEN is sufficient. Requires the `contents.write` permission. | | ||
| enable_auto_rollout | `false` | When enabled, the action will trigger a rollout for any configuration that has been updated. | | ||
|
||
## Usage | ||
|
||
### Export Resources | ||
|
||
To get started, you must handle exporting your existing resources to the repository. Use | ||
the `bindplane get` commands with the `--export` flag. | ||
|
||
```bash | ||
bindplane get destination -o yaml --export > destination.yaml | ||
bindplane get configuration -o yaml --export > configuration.yaml | ||
``` | ||
|
||
With the resources exported to the repository, you can move on to configuring the action | ||
using a new workflow. | ||
|
||
### Workflow | ||
|
||
The following workflow can be used as an example. It uses the same file paths | ||
created in the [Export Resources](#export-resources) section. | ||
|
||
This example will write the raw OTEL configurations back to the repository at the | ||
path `otel/` | ||
|
||
```yaml | ||
name: bindplane | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
|
||
# Write back requires access to the repo | ||
permissions: | ||
contents: write | ||
|
||
# Run commits in order to prevent out of order write back commits. | ||
concurrency: | ||
group: ${{ github.head_ref || github.ref_name }} | ||
cancel-in-progress: false | ||
|
||
jobs: | ||
bindplane: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- uses: observIQ/bindplane-op-action@main | ||
with: | ||
bindplane_remote_url: ${{ secrets.BINDPLANE_REMOTE_URL }} | ||
bindplane_username: ${{ secrets.BINDPLANE_USERNAME }} | ||
bindplane_password: ${{ secrets.BINDPLANE_PASSWORD }} | ||
target_branch: main | ||
destination_path: destination.yaml | ||
configuration_path: configuration.yaml | ||
enable_otel_config_write_back: true | ||
configuration_output_dir: otel/ | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
enable_auto_rollout: true | ||
``` | ||
|
||
After the action is executed, you can expect to see OTEL configurations | ||
in the `otel/` directory. | ||
|
||
``` | ||
otel | ||
├── k8s-cluster.yaml | ||
├── k8s-gateway.yaml | ||
└── k8s-node.yaml | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: 'BindPlane OP Action' | ||
description: 'GitHub Action for BindPlane OP.' | ||
author: 'observIQ' | ||
|
||
inputs: | ||
bindplane_remote_url: | ||
description: 'The URL that will be used to connect to BindPlane OP' | ||
required: true | ||
bindplane_api_key: | ||
description: 'The BindPlane OP API key that will be used to authenticate to BindPlane OP' | ||
bindplane_username: | ||
description: 'The BindPlane OP bindplane_username that will be used to authenticate to BindPlane OP' | ||
bindplane_password: | ||
description: 'The BindPlane OP bindplane_password that will be used to authenticate to BindPlane OP' | ||
target_branch: | ||
description: 'Resource apply and OTEL config write back will only happen when this branch is the current branch of the action' | ||
destination_path: | ||
description: 'Path to the file which contains the BindPlane destination resources' | ||
configuration_path: | ||
description: 'Path to the file which contains the BindPlane configuration resources' | ||
enable_otel_config_write_back: | ||
description: 'Enable OTEL raw config write back' | ||
default: false | ||
configuration_output_dir: | ||
description: 'Path to the directory which will contain the rendered OTEL format of the configuration resources' | ||
token: | ||
description: 'The GitHub token used to authenticate to GitHub when writing OTEL configs back to the repo' | ||
enable_auto_rollout: | ||
description: 'When enabled, the action will trigger a rollout for all configurations that have been updated' | ||
default: false | ||
|
||
runs: | ||
using: 'docker' | ||
image: 'Dockerfile' | ||
# Arg order must match the order of the arg parsing | ||
# in entrypoint.sh. | ||
args: | ||
- ${{ inputs.bindplane_remote_url }} | ||
- ${{ inputs.bindplane_api_key }} | ||
- ${{ inputs.bindplane_username }} | ||
- ${{ inputs.bindplane_password }} | ||
- ${{ inputs.target_branch }} | ||
- ${{ inputs.destination_path }} | ||
- ${{ inputs.configuration_path }} | ||
- ${{ inputs.enable_otel_config_write_back }} | ||
- ${{ inputs.configuration_output_dir }} | ||
- ${{ inputs.token }} | ||
- ${{ inputs.enable_auto_rollout }} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the PR instructions it has plural of these file names
destinations.yaml
andconfigurations.yaml
what do we want? It failed for me as I followed the PR instructions.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like you got it working. The path you export the initial resources too should match whatever you configure your action to point to, in your repo you have:
but you could have anything. My example repo has the following structure:
Where
resources/
is the top level directory for my destinations and configurations. The output dir isotel
.