Files
coverage-comment-action/src/add-to-wiki

29 lines
637 B
Plaintext
Raw Normal View History

2021-09-25 11:54:56 +02:00
#!/bin/bash
# Usage $0 {owner/repo} {filename} {commit_message}
# Stores the content of stdin in a file named {filename} in the wiki of
# the provided repo
# Reads envvar GITHUB_TOKEN
set -eux
stdin="$(cat -)"
repo_name="${1}"
filename="${2}"
commit_message="${3}"
dir="$(mktemp -d)"
cd $dir
git clone "https://${GITHUB_TOKEN}@github.com/${repo_name}.wiki.git" .
echo $stdin > "${filename}"
if ! git diff --exit-code
then
git add "${filename}"
git config --global user.email "coverage-comment-action"
git config --global user.name "Coverage Comment Action"
git commit -m "$commit_message"
git push -u origin
fi