diff --git a/Dockerfile b/Dockerfile index 0fd0594..64cc29b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,7 +4,7 @@ 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 @@ -12,10 +12,20 @@ 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 diff --git a/docker-compose.yml b/docker-compose.yml index 7e8ed92..88a3b7b 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -8,6 +8,8 @@ services: volumes: - .:/app/ - ~/.gitconfig:/root/.gitconfig:ro + - ~/.ssh:/root/.ssh/:ro + docs: build: context: . diff --git a/src/Dockerfile b/src/Dockerfile index 162bc47..b24c8db 100644 --- a/src/Dockerfile +++ b/src/Dockerfile @@ -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 \ diff --git a/src/entrypoint.sh b/src/entrypoint.sh index 8869014..ca5055e 100755 --- a/src/entrypoint.sh +++ b/src/entrypoint.sh @@ -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 diff --git a/src/sync_template.sh b/src/sync_template.sh index aab3ede..34cb434 100755 --- a/src/sync_template.sh +++ b/src/sync_template.sh @@ -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 @@ -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