Skip to content

Commit

Permalink
Fix/add ssh (#15)
Browse files Browse the repository at this point in the history
* fix(): add ssh agent to DEV docker container

* fix(): change git pull strategy

* fix(): change git pull strategy

* fix(): switch github user name to GITHUB_ACTOR

* fix(): switch github user name to GITHUB_ACTOR

* fix(): switch from github-cli to hub

* fix(): fix validation gate
  • Loading branch information
AndreasAugustin authored Jun 13, 2020
1 parent 965a1a0 commit 7ec755b
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 14 deletions.
20 changes: 15 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,28 @@
FROM golang:1.14-alpine as DEV

# install packages
RUN apk add --update --no-cache bash make git zsh curl tmux musl build-base
RUN apk add --update --no-cache bash make git zsh curl tmux musl build-base openssh

# Make zsh your default shell for tmux
RUN echo "set-option -g default-shell /bin/zsh" >> /root/.tmux.conf

# install oh-my-zsh
RUN sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)"

RUN git clone https://github.com/cli/cli.git gh-cli \
&& cd gh-cli \
&& make \
&& mv ./bin/gh /usr/local/bin/
# github-cli not stable yet
#RUN git clone https://github.com/cli/cli.git gh-cli \
# && cd gh-cli \
# && make \
# && mv ./bin/gh /usr/local/bin/

RUN apk add --update --no-cache groff util-linux
RUN git clone \
--config transfer.fsckobjects=false \
--config receive.fsckobjects=false \
--config fetch.fsckobjects=false \
https://github.com/github/hub.git \
&& cd hub \
&& make install prefix=/usr/local

WORKDIR /app

Expand Down
2 changes: 2 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ services:
volumes:
- .:/app/
- ~/.gitconfig:/root/.gitconfig:ro
- ~/.ssh:/root/.ssh/:ro

docs:
build:
context: .
Expand Down
18 changes: 14 additions & 4 deletions src/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,20 @@ LABEL \
# install packages
RUN apk add --update --no-cache bash make git zsh curl tmux musl build-base

RUN git clone https://github.com/cli/cli.git gh-cli \
&& cd gh-cli \
&& make \
&& mv ./bin/gh /usr/local/bin/
# github-cli not stable yet
#RUN git clone https://github.com/cli/cli.git gh-cli \
# && cd gh-cli \
# && make \
# && mv ./bin/gh /usr/local/bin/

RUN apk add --update --no-cache groff util-linux
RUN git clone \
--config transfer.fsckobjects=false \
--config receive.fsckobjects=false \
--config fetch.fsckobjects=false \
https://github.com/github/hub.git \
&& cd hub \
&& make install prefix=/usr/local

ADD *.sh /bin/
RUN chmod +x /bin/entrypoint.sh \
Expand Down
2 changes: 1 addition & 1 deletion src/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ SOURCE_REPO="https://${GITHUB_ACTOR}:${GITHUB_TOKEN}@github.com/${SOURCE_REPO_PA

echo "set git global configuration"
git config --global user.email "github-action@actions-template-sync.noreply.github.com@"
git config --global user.name "actions-template-sync"
git config --global user.name "${GITHUB_ACTOR}"

source sync_template.sh
19 changes: 15 additions & 4 deletions src/sync_template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ if [[ -z "${SOURCE_REPO}" ]]; then
exit 1;
fi

if ! [ -x "$(command -v gh)" ]; then
echo "Error: github-cli gh is not installed. 'https://github.com/cli/cli'" >&2;
# if ! [ -x "$(command -v gh)" ]; then
# echo "Error: github-cli gh is not installed. 'https://github.com/cli/cli'" >&2;
# exit 1;
# fi

if ! [ -x "$(command -v hub)" ]; then
echo "Error: hub is not installed. 'https://github.com/github/hub'" >&2;
exit 1;
fi

Expand All @@ -17,10 +22,16 @@ echo "start sync"
echo "create new branch from default branch with name ${NEW_BRANCH}"
git checkout -b ${NEW_BRANCH}
echo "pull changes from template"
git pull "${SOURCE_REPO}" --allow-unrelated-histories
git pull "${SOURCE_REPO}" --allow-unrelated-histories --squash --strategy=recursive -X theirs
git add .
git commit -m "chore(template): merge template changes :up:"
echo "push changes"
git push --set-upstream origin "${NEW_BRANCH}"
echo "create pull request"
gh pr create -b master -f -l chore
# Workaround for `hub` auth error https://github.com/github/hub/issues/2149#issuecomment-513214342
export GITHUB_USER="$GITHUB_ACTOR"
hub pull-request \
-b master \
-h $NEW_BRANCH \
--no-edit
# gh pr create -B master -f -l chore

0 comments on commit 7ec755b

Please sign in to comment.