Skip to content

Commit

Permalink
fix(github-action): set author/comitter
Browse files Browse the repository at this point in the history
  • Loading branch information
Duologic committed Jul 2, 2021
1 parent 85ce9dd commit 333bad5
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
- "uses": "actions/checkout@v2"
- "env":
"GEN_COMMIT": "${{ github.ref == 'refs/heads/master' && github.repository == 'jsonnet-libs/k8s' }}"
"GIT_COMMITTER_EMAIL": "[email protected]"
"GIT_COMMITTER_NAME": "jsonnet-libs-bot"
"SSH_KEY": "${{ secrets.DEPLOY_KEY }}"
"run": "make build libs/cert-manager"
"cnrm":
Expand All @@ -18,6 +20,8 @@
- "uses": "actions/checkout@v2"
- "env":
"GEN_COMMIT": "${{ github.ref == 'refs/heads/master' && github.repository == 'jsonnet-libs/k8s' }}"
"GIT_COMMITTER_EMAIL": "[email protected]"
"GIT_COMMITTER_NAME": "jsonnet-libs-bot"
"SSH_KEY": "${{ secrets.DEPLOY_KEY }}"
"run": "make build libs/cnrm"
"crossplane":
Expand All @@ -28,6 +32,8 @@
- "uses": "actions/checkout@v2"
- "env":
"GEN_COMMIT": "${{ github.ref == 'refs/heads/master' && github.repository == 'jsonnet-libs/k8s' }}"
"GIT_COMMITTER_EMAIL": "[email protected]"
"GIT_COMMITTER_NAME": "jsonnet-libs-bot"
"SSH_KEY": "${{ secrets.DEPLOY_KEY }}"
"run": "make build libs/crossplane"
"debugging":
Expand All @@ -48,6 +54,8 @@
- "uses": "actions/checkout@v2"
- "env":
"GEN_COMMIT": "${{ github.ref == 'refs/heads/master' && github.repository == 'jsonnet-libs/k8s' }}"
"GIT_COMMITTER_EMAIL": "[email protected]"
"GIT_COMMITTER_NAME": "jsonnet-libs-bot"
"SSH_KEY": "${{ secrets.DEPLOY_KEY }}"
"run": "make build libs/istio"
"k8s":
Expand All @@ -58,6 +66,8 @@
- "uses": "actions/checkout@v2"
- "env":
"GEN_COMMIT": "${{ github.ref == 'refs/heads/master' && github.repository == 'jsonnet-libs/k8s' }}"
"GIT_COMMITTER_EMAIL": "[email protected]"
"GIT_COMMITTER_NAME": "jsonnet-libs-bot"
"SSH_KEY": "${{ secrets.DEPLOY_KEY }}"
"run": "make build libs/k8s"
"repos":
Expand Down
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ IMPORTS=$(shell find libs -name config.jsonnet | xargs -I {} echo "(import '{}')
PAGES ?= false
GEN_COMMIT ?= false
GITHUB_SHA ?= $(shell git rev-parse HEAD)
GIT_AUTHOR_NAME ?= $(shell git --no-pager log --format=format:'%an' -n 1)
GIT_AUTHOR_EMAIL ?= $(shell git --no-pager log --format=format:'%ae' -n 1)
GIT_COMITTER_NAME ?= $(shell git --no-pager log --format=format:'%an' -n 1)
GIT_COMITTER_EMAIL ?= $(shell git --no-pager log --format=format:'%ae' -n 1)

.DEFAULT_GOAL: default
default:
Expand Down Expand Up @@ -48,6 +52,10 @@ libs/*:
-v $(ABS_OUTPUT_DIR):/output \
-e GEN_COMMIT="$(GEN_COMMIT)" \
-e GITHUB_SHA="$(GITHUB_SHA)" \
-e GIT_AUTHOR_NAME="$(GIT_AUTHOR_NAME)" \
-e GIT_AUTHOR_EMAIL="$(GIT_AUTHOR_EMAIL)" \
-e GIT_COMITTER_NAME="$(GIT_COMITTER_NAME)" \
-e GIT_COMITTER_EMAIL="$(GIT_COMITTER_EMAIL)" \
-e SSH_KEY="$${SSH_KEY}" \
$(IMAGE_PREFIX)/$(IMAGE_NAME):$(IMAGE_TAG) /config /output

Expand Down
2 changes: 2 additions & 0 deletions jsonnet/github_action.jsonnet
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ local libJob(name) = {
{
run: 'make build libs/' + name,
env: {
GIT_COMMITTER_NAME: 'jsonnet-libs-bot',
GIT_COMMITTER_EMAIL: '[email protected]',
SSH_KEY: '${{ secrets.DEPLOY_KEY }}',
GEN_COMMIT: "${{ github.ref == 'refs/heads/master' && github.repository == 'jsonnet-libs/k8s' }}",
},
Expand Down
3 changes: 3 additions & 0 deletions scripts/configure_github_ssh.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,14 @@ set -x
DIRNAME="$1"

mkdir "${DIRNAME}"/ssh

echo "${SSH_KEY}" > "${DIRNAME}"/ssh/id_rsa
echo "Host github.com" > "${DIRNAME}"/ssh/config
echo " IdentityFile ${DIRNAME}/ssh/id_rsa" >> "${DIRNAME}"/ssh/config
echo " UserKnownHostsFile ${DIRNAME}/ssh/known_hosts" >> "${DIRNAME}"/ssh/config
cat "${DIRNAME}"/ssh/config

ssh-keyscan github.com >> "${DIRNAME}"/ssh/known_hosts

chmod 700 -R "${DIRNAME}"/ssh
chmod 600 "${DIRNAME}"/ssh/id_rsa

0 comments on commit 333bad5

Please sign in to comment.