Skip to content

Instantly share code, notes, and snippets.

View suzuki-shunsuke's full-sized avatar

Shunsuke Suzuki suzuki-shunsuke

View GitHub Profile
.*\[ci skip\].*|.*\[CI SKIP\].*|.*\[skip ci\].*|.*\[SKIP CI\].*
#!/usr/bin/env bash
set -eu
if [ -z "${CODEBUILD_WEBHOOK_EVENT:-}" ]; then
repo=$(echo "${CODEBUILD_SOURCE_REPO_URL}" | sed -E "s|https://github\.com/(.*)$|\1|" | sed -E "s|\.git$||")
# https://docs.github.com/en/rest/reference/repos#list-pull-requests-associated-with-a-commit
body=$(curl \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.groot-preview+json" \
@suzuki-shunsuke
suzuki-shunsuke / sentry_example.go
Created August 1, 2020 00:35
Example of sentry-go
package sentry
import (
"time"
"github.com/getsentry/sentry-go"
)
type Event struct {
Error error
commands:
apply:
description: |
Run `terraform apply` and add a comment to the pull request or Git commit.
parameters:
apply_options:
default: ""
description: |
The options of `terraform apply` command. The option `-auto-approve` is set automatically.
For example, `-refresh=false -parallelism=20`.
@suzuki-shunsuke
suzuki-shunsuke / create-event-definition.sh
Created December 3, 2019 00:30
Graylog Event Definition and Event Notification API (Graylog v3.1.2) https://github.com/suzuki-shunsuke/go-graylog/issues/170
curl -u admin:admin -H 'Content-Type: application/json' -H 'Accept: application/json' -H 'X-Requested-By: api' -X POST 'http://127.0.0.1:9000/api/events/definitions?pretty=true' -d '
{
"title": "new-event-definition",
"description": "",
"priority": 2,
"alert": true,
"config": {
"type": "aggregation-v1",
"query": "test",
"streams": [
@suzuki-shunsuke
suzuki-shunsuke / README.md
Last active December 2, 2019 13:49
突撃!隣のTerraform

最初に 5 ~ 10 分程度お時間を頂いて本日お時間を頂いた経緯などを説明したあと、色々お話を聞かせてもらえたらと思います。

本日のトピックを簡潔に言うと

  • 如何に Terraform の state を分割するか
  • 如何に Terraform によるリソースの管理を SRE から developer に委譲するか

弊社の現状の簡単な説明

  • AWS のリソースを Terraform で管理している
package main
import (
"fmt"
"os"
"os/exec"
)
func main() {
cmd := exec.Command("sh", "-c", "ls | fzf")
@suzuki-shunsuke
suzuki-shunsuke / send-pr.sh
Last active September 20, 2019 12:56
The shell function to create a pull request from the current feature branch.
send-pr() {
local remote=`git config branch.master.remote`
local remote_url=`git config remote.${remote}.url`
case "$remote_url" in
https://github.com*)
git-pr
;;
https://ghe.example.com*)
ghe-pr
;;
@suzuki-shunsuke
suzuki-shunsuke / dctag.sh
Created August 7, 2019 11:09
The shell function to list Docker image tags. It depends on https://github.com/genuinetools/reg .
dctag() {
if [ $# -eq 0 -o "$1" = "help" -o "$1" = "--help" -o "$1" = "-help" ]; then
cat << EOS
List Docker image tags
Usage: $ dctag <image name>
ex. $ dctag alpine
EOS
return 0
fi
if [ $# -ne 1 ]; then
@suzuki-shunsuke
suzuki-shunsuke / create-docker-config-json.sh
Last active August 4, 2019 03:07
The one liner to create a ~/.docker/config.json for CI/CD. The environment variables USER_NAME, PASSWORD, and REGISTRY are parameters to login the Docker registry.
docker run -v /var/run/docker.sock:/var/run/docker.sock -ti --rm -e USER_NAME=$USER_NAME -e PASSWORD=$PASSWORD docker:19.03.1 sh -c 'echo $PASSWORD | docker login $REGISTRY --username $USER_NAME --password-stdin > /dev/null 2> /tmp/error.txt && cat /root/.docker/config.json || (cat /tmp/error.txt >&2 && exit 1)'