-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
48 changed files
with
3,590 additions
and
0 deletions.
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 @@ | ||
node_modules |
Validating CODEOWNERS rules …
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 @@ | ||
* @karl-johan-grahn |
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,6 @@ | ||
version: 2 | ||
updates: | ||
- package-ecosystem: "github-actions" | ||
directory: ".github/workflows" | ||
schedule: | ||
interval: "daily" |
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,7 @@ | ||
{ | ||
"ignorePatterns": [ | ||
{ | ||
"pattern": "^http" | ||
} | ||
] | ||
} |
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,15 @@ | ||
name: Docker image | ||
|
||
on: | ||
push: | ||
branches: main | ||
pull_request: | ||
branches: main | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Build the Docker image | ||
run: make image.iid |
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,17 @@ | ||
name: Dockerfile lint | ||
|
||
on: | ||
push: | ||
branches: main | ||
pull_request: | ||
branches: main | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Docker lint | ||
uses: hadolint/[email protected] | ||
with: | ||
dockerfile: Dockerfile | ||
failure-threshold: warning |
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,44 @@ | ||
name: Docker publish | ||
|
||
on: | ||
push: | ||
branches: main | ||
# Publish semantic version tags as releases | ||
tags: [ '^[0-9]+.[0-9]+.[0-9]+$' ] | ||
pull_request: | ||
branches: main | ||
|
||
env: | ||
REGISTRY: ghcr.io | ||
IMAGE_NAME: ${{github.repository}} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v2 | ||
# Login against a Docker registry except on PR | ||
- name: Log into Docker registry ${{env.REGISTRY}} | ||
if: github.event_name != 'pull_request' | ||
uses: docker/[email protected] | ||
with: | ||
registry: ${{env.REGISTRY}} | ||
username: ${{github.actor}} | ||
password: ${{secrets.GITHUB_TOKEN}} | ||
# Extract metadata for Docker for subsequent registry push | ||
- name: Extract Docker metadata | ||
id: meta | ||
uses: docker/[email protected] | ||
with: | ||
images: ${{env.REGISTRY}}/${{env.IMAGE_NAME}} | ||
# Build and push Docker image with Buildx (don't push on PR) | ||
- name: Build and push Docker image | ||
uses: docker/[email protected] | ||
with: | ||
context: . | ||
push: ${{github.event_name != 'pull_request'}} | ||
tags: ${{steps.meta.outputs.tags}} | ||
labels: ${{steps.meta.outputs.labels}} |
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,44 @@ | ||
name: Documentation checks | ||
|
||
on: | ||
push: | ||
branches: main | ||
pull_request: | ||
branches: main | ||
jobs: | ||
link_check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Link check | ||
uses: gaurav-nelson/github-action-markdown-link-check@v1 | ||
with: | ||
config-file: .github/md_config.json | ||
spell_check: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Spell check | ||
uses: errata-ai/[email protected] | ||
with: | ||
styles: https://github.com/errata-ai/write-good/releases/latest/download/write-good.zip | ||
files: docs/src | ||
env: | ||
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}} | ||
build_and_deploy: | ||
runs-on: ubuntu-latest | ||
concurrency: | ||
group: ${{github.workflow}}-${{github.ref}} | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Setup mdBook | ||
uses: peaceiris/actions-mdbook@v1 | ||
with: | ||
mdbook-version: 0.4.13 | ||
- run: mdbook build ./docs | ||
- name: Deploy | ||
uses: peaceiris/actions-gh-pages@v3 | ||
if: ${{github.ref == 'refs/heads/main'}} | ||
with: | ||
github_token: ${{secrets.GITHUB_TOKEN}} | ||
publish_dir: ./book |
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,37 @@ | ||
name: Go lint, build, and test | ||
|
||
on: | ||
push: | ||
branches: main | ||
pull_request: | ||
branches: main | ||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
container: ghcr.io/opencontainers/golangci-lint:v1.39.0 | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Lint | ||
run: make lint | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.1 | ||
- name: Build | ||
run: make build | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
- name: Set up Go | ||
uses: actions/setup-go@v2 | ||
with: | ||
go-version: 1.17.1 | ||
- name: Formatting | ||
run: if [ -n "$(go fmt)" ]; then echo 'Code is not formatted with "go fmt"'; false; fi | ||
- name: Test | ||
run: make test |
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,46 @@ | ||
# Binaries for programs and plugins | ||
*.exe | ||
*.exe~ | ||
*.dll | ||
*.so | ||
*.dylib | ||
|
||
# Test binary, build with `go test -c` | ||
*.test | ||
|
||
# Output of the go coverage tool, specifically when used with LiteIDE | ||
*.out | ||
|
||
# Jetbrains | ||
*.iml | ||
*.ipr | ||
*.iws | ||
.idea | ||
|
||
# misc | ||
.DS_Store | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
|
||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
|
||
# web dependencies | ||
/web/node_modules | ||
|
||
# web build dir | ||
/web/build | ||
|
||
# test and coverage | ||
coverage.xml | ||
coverage.html | ||
|
||
bin | ||
c.out | ||
*.iid | ||
*.tag | ||
*.cid | ||
/version.txt |
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,7 @@ | ||
StylesPath = spellingstyles | ||
MinAlertLevel = warning | ||
|
||
# Only check MarkDown files | ||
[*.md] | ||
|
||
BasedOnStyles = Vale |
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,9 @@ | ||
# Changelog | ||
All notable changes to this project will be documented in this file. | ||
|
||
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), | ||
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). | ||
|
||
## [0.1.0] - 2021-10-18 | ||
### Adds | ||
- Initial commit |
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,27 @@ | ||
FROM golang:1.17.1 AS builder | ||
|
||
WORKDIR /go/src/github.com/karl-johan-grahn/devopsbot | ||
|
||
COPY . ./ | ||
|
||
RUN make build | ||
|
||
FROM alpine:3.14.2 | ||
|
||
RUN apk add --no-cache ca-certificates=20191127-r5 | ||
|
||
ARG VERSION | ||
ARG REVISION | ||
|
||
LABEL org.opencontainers.image.url="ghcr.io/karl-johan-grahn/devopsbot" | ||
LABEL org.opencontainers.image.source="https://github.com/karl-johan-grahn/devopsbot" | ||
LABEL org.opencontainers.image.version=$VERSION | ||
LABEL org.opencontainers.image.revision=$REVISION | ||
|
||
COPY --from=builder /go/src/github.com/karl-johan-grahn/devopsbot/bin/devopsbot /devopsbot | ||
# Copy over string translations | ||
COPY --from=builder /go/src/github.com/karl-johan-grahn/devopsbot/bot/active.*.json / | ||
|
||
USER 1001:1001 | ||
|
||
CMD [ "/devopsbot" ] |
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,73 @@ | ||
PREFIX := . | ||
PKG_NAME := devopsbot | ||
SHELL := /bin/bash | ||
.SHELLFLAGS := -euxo pipefail -c | ||
|
||
export GOPRIVATE=github.com/karl-johan-grahn/devopsbot | ||
|
||
REVISION = $(shell git rev-parse --short HEAD) | ||
VERSION = $(shell cat version.txt) | ||
|
||
REVISION_FLAG = -X $(shell go list ./version).Revision=$(REVISION) | ||
VERSION_FLAG = -X $(shell go list ./version).Version=$(VERSION) | ||
|
||
# Get the string before and after the forward slash of go version arch | ||
GOOS ?= $(shell go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\1/') | ||
GOARCH ?= $(shell go version | sed 's/^.*\ \([a-z0-9]*\)\/\([a-z0-9]*\)/\2/') | ||
|
||
version.txt: | ||
@./gen_version.sh > $@ | ||
|
||
image.iid: version.txt Dockerfile | ||
@docker build \ | ||
--build-arg REVISION=$(REVISION) \ | ||
--build-arg VERSION=$(VERSION) \ | ||
--iidfile $@ \ | ||
. | ||
|
||
lint: | ||
@golangci-lint run --disable-all \ | ||
--enable deadcode \ | ||
--enable depguard \ | ||
--enable dupl \ | ||
--enable errcheck \ | ||
--enable goconst \ | ||
--enable gocritic \ | ||
--enable gocyclo \ | ||
--enable gofmt \ | ||
--enable goimports \ | ||
--enable gosec \ | ||
--enable gosimple \ | ||
--enable govet \ | ||
--enable ineffassign \ | ||
--enable misspell \ | ||
--enable nakedret \ | ||
--enable prealloc \ | ||
--enable staticcheck \ | ||
--enable structcheck \ | ||
--enable stylecheck \ | ||
--enable typecheck \ | ||
--enable unconvert \ | ||
--enable unused \ | ||
--enable varcheck | ||
|
||
$(PREFIX)/bin/$(PKG_NAME)_%: version.txt go.mod go.sum $(shell find $(PREFIX) -type f -name '*.go') | ||
GO111MODULE=on GOOS=$(shell echo $* | cut -f1 -d-) GOARCH=$(shell echo $* | cut -f2 -d- | cut -f1 -d.) CGO_ENABLED=0 \ | ||
go build \ | ||
-ldflags "$(REVISION_FLAG) $(VERSION_FLAG)" \ | ||
-o $@ \ | ||
./cmd/$(PKG_NAME) | ||
|
||
$(PREFIX)/bin/$(PKG_NAME): $(PREFIX)/bin/$(PKG_NAME)_$(GOOS)-$(GOARCH) | ||
cp $< $@ | ||
|
||
build: $(PREFIX)/bin/$(PKG_NAME) | ||
|
||
clean: | ||
@-rm -Rf $(PREFIX)/bin | ||
@-rm -f $(PREFIX)/*.[ci]id $(PREFIX)/*.tag $(PREFIX)/version.txt $(PREFIX)/c.out | ||
|
||
test: build | ||
go test -v -coverprofile=c.out ./... | ||
|
||
.PHONY: all build clean test lint |
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,13 @@ | ||
# Devopsbot - Development Operations Bot | ||
Devopsbot is a Slack bot written in Go using the [Slack API in Go](https://github.com/slack-go/slack). | ||
It improves development efficiency by automating tasks such as: | ||
- Declaring incidents | ||
- Resolving incidents | ||
|
||
The bot essentially automates the Incident Command System (ICS). | ||
|
||
## Design Principles | ||
The application is built around three key principles: | ||
1. Everything the bot can do, any person is able to do - if it goes down and is unavailable, it will not block anyone | ||
1. Secrets are maintained externally, for example via Hashicorp Vault | ||
1. Configuration is maintained externally, for example via Kubernetes config maps |
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,28 @@ | ||
{ | ||
"ArchiveIncidentChannel": "Archive incident channel", | ||
"BroadcastChannel": "Broadcast channel", | ||
"BroadcastChannelHint": "DevOpsBot will be invited to this channel if it is not already a member", | ||
"Cancel": "Cancel", | ||
"Commander": "Commander", | ||
"DeclareIncident": "Declare incident", | ||
"DeclareNewIncident": "Declare a new incident", | ||
"Environment": "Environment", | ||
"HelpMessage": "These are the available commands:\n> `/devopsbot help` - Get this help\n> `/devopsbot incident` - Declare an incident\n> `/devopsbot resolve` - Resolve an incident", | ||
"Incident": "Incident", | ||
"IncidentChannelNamePattern": "Choose a channel that starts with 'inc_'", | ||
"IncidentCreationDescription": "This will create a slack channel #inc_<Incident Name>_<date>, and notify the organization about the incident", | ||
"IncidentName": "Incident name", | ||
"IncidentNameHint": "Incident names may only contain lowercase letters, numbers, hyphens, and underscores, and must be 60 characters or less", | ||
"Invitees": "Invitees", | ||
"No": "No", | ||
"Region": "Region", | ||
"Resolution": "Resolution", | ||
"ResolveAnIncident": "Resolve an incident", | ||
"ResolveIncident": "Resolve incident", | ||
"ResolveIncidentDescription": "This will resolve an incident by archiving the incident slack channel and notify the organization about the resolution", | ||
"Responder": "Responder", | ||
"SecurityIncident": "Security Incident", | ||
"SecurityIncidentLabel": "Mark to make incident channel private", | ||
"Summary": "Summary", | ||
"Yes": "Yes" | ||
} |
Oops, something went wrong.