From c2964ec1bb4938a7b31af53db463d37a9f8a9c2a Mon Sep 17 00:00:00 2001 From: whyour Date: Sun, 11 Apr 2021 23:21:43 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0dust=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E7=A7=98=E9=92=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/docker.yml | 10 +++++++--- docker/Dockerfile | 10 +++++++--- shell/git_diy.sh | 5 ++++- 3 files changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml index 4be06957..f8029249 100644 --- a/.github/workflows/docker.yml +++ b/.github/workflows/docker.yml @@ -30,9 +30,11 @@ jobs: echo "${DOCKER_PASSWORD}" | docker login --username "${DOCKER_USERNAME}" --password-stdin - name: Docker buildx image and push on master branch + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} if: github.ref == 'refs/heads/master' run: | - docker buildx build --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag whyour/qinglong:latest docker/ + docker buildx build --build-arg SSH_PRIVATE_KEY="${SSH_PRIVATE_KEY}" --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag whyour/qinglong:latest docker/ - name: Replace tag without `v` if: startsWith(github.ref, 'refs/tags/') @@ -44,7 +46,9 @@ jobs: result-encoding: string - name: Docker buildx image and push on release + env: + SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} if: startsWith(github.ref, 'refs/tags/') run: | - docker buildx build --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag whyour/qinglong:${{steps.version.outputs.result}} docker/ - docker buildx build --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag whyour/qinglong:latest docker/ \ No newline at end of file + docker buildx build --build-arg SSH_PRIVATE_KEY="${SSH_PRIVATE_KEY}" --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag whyour/qinglong:${{steps.version.outputs.result}} docker/ + docker buildx build --build-arg SSH_PRIVATE_KEY="${SSH_PRIVATE_KEY}" --output "type=image,push=true" --platform=linux/amd64,linux/arm/v7,linux/arm64 --tag whyour/qinglong:latest docker/ \ No newline at end of file diff --git a/docker/Dockerfile b/docker/Dockerfile index b759760d..ff8a82fa 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -2,6 +2,7 @@ FROM node:lts-alpine LABEL maintainer="whyour" ARG QL_BASE_URL=https://github.com.cnpmjs.org/whyour/qinglong ARG QL_BASE_BRANCH=master +ARG SSH_PRIVATE_KEY ENV PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ LANG=zh_CN.UTF-8 \ SHELL=/bin/bash \ @@ -15,19 +16,22 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories coreutils \ moreutils \ git \ - wget \ curl \ - nano \ tzdata \ perl \ openssl \ nginx \ python3 \ - yarn \ jq \ + openssh \ && rm -rf /var/cache/apk/* \ && ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime \ && echo "Asia/Shanghai" > /etc/timezone \ + && mkdir -p /root/.ssh \ + && chmod 700 /root/.ssh \ + && echo -e $SSH_PRIVATE_KEY > /root/.ssh/id_rsa \ + && chmod 600 /root/.ssh/id_rsa \ + && ssh-keyscan github.com > /root/.ssh/known_hosts \ && touch ~/.bashrc \ && mkdir /run/nginx \ && git clone -b ${QL_BASE_BRANCH} ${QL_BASE_URL} ${QL_DIR} \ diff --git a/shell/git_diy.sh b/shell/git_diy.sh index 839c6fe8..7bf703ff 100755 --- a/shell/git_diy.sh +++ b/shell/git_diy.sh @@ -32,7 +32,10 @@ mkdir -p ${diyscriptsdir} if [ ! -d "$diyscriptsdir/${author}_${repo}" ]; then echo -e "${author}本地仓库不存在,从gayhub拉取ing..." - cd ${diyscriptsdir} && git clone https://ghproxy.com/https://github.com/${author}/${repo} ${author}_${repo} + local url="https://ghproxy.com/https://github.com/${author}/${repo}" + if [ $author == "monk-coder" ] && [ $repo == "dust" ]; then + url="git@github.com:monk-coder/dust.git" + cd ${diyscriptsdir} && git clone $url ${author}_${repo} gitpullstatus=$? [ $gitpullstatus -eq 0 ] && echo -e "${author}本地仓库拉取完毕" [ $gitpullstatus -ne 0 ] && echo -e "${author}本地仓库拉取失败,请检查!" && exit 0