From b668261aaa3468bfff6f513237a4fb2e67b1330a Mon Sep 17 00:00:00 2001 From: notevery Date: Tue, 19 Apr 2022 09:53:05 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E9=95=9C=E5=83=8F?= =?UTF-8?q?=EF=BC=8C=E4=BC=98=E5=8C=96=E5=8F=91=E7=89=88action?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .github/workflows/release.yml | 117 ++++++++++------------------------ Dockerfile | 16 +---- 2 files changed, 36 insertions(+), 97 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3fb069683..2f92254f3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,109 +1,58 @@ name: release on: - workflow_dispatch: - inputs: - dev_version: - description: 'the tag of the image to release, like `dev-6-02dbc80`' - default: 'v2dev' - required: true - prod_version: - description: 'the tag of the image,src to release, like `2.2.3`' - default: '' - required: true push: tags: - '2.*.*' - '!v1.*.*' jobs: - reTagAndPush: + tag2image: runs-on: ubuntu-latest steps: - ## 自动触发的时候,dev_version 默认为 v2dev - ## prod_version 默认为 ${{ github.ref_name}} - - id: set-version - run: | - DEVVERSIONIN=${{ github.event.inputs.dev_version }} - DEVVERSION=${DEVVERSIONIN:-"v2dev"} - PRODVERSIONIN=${{ github.event.inputs.prod_version }} - PRODVERSION=${PRODVERSIONIN:-"${{ github.ref_name}}"} - echo "DEVVERSION=$DEVVERSION" >> $GITHUB_ENV - echo "PRODVERSION=$PRODVERSION" >> $GITHUB_ENV - - run: echo "${DEVVERSION}" - - run: echo "${PRODVERSION}" + - name: Checkout + uses: actions/checkout@v3 + with: + ref: "${{ github.ref_name}}" - id: get-versions run: | - sversion="${PRODVERSION}" + sversion="${{ github.ref_name}}" echo "::set-output name=sversion::${sversion: 0 :3}" - echo "::set-output name=DEVVERSION::${DEVVERSION}" - echo "::set-output name=PRODVERSION::${PRODVERSION}" - - run: | - echo "${{steps.get-versions.outputs.sversion}}" - echo "${{steps.get-versions.outputs.DEVVERSION}}" - echo "${{steps.get-versions.outputs.PRODVERSION}}" - - name: ReTag to Dockerhub 2.x.y - uses: onichandame/docker-registry-sync-action@master - with: - source_repository: "docker.io/longguikeji/arkid:${{steps.get-versions.outputs.DEVVERSION}}" - source_username: "${{ secrets.DOCKERHUBUSERNAME }}" - source_password: "${{ secrets.DOCKERHUBPWD }}" - target_repository: "docker.io/longguikeji/arkid:${{steps.get-versions.outputs.PRODVERSION}}" - target_username: "${{ secrets.DOCKERHUBUSERNAME }}" - target_password: "${{ secrets.DOCKERHUBPWD }}" - - name: ReTag to Dockerhub 2.x - uses: onichandame/docker-registry-sync-action@master - with: - source_repository: "docker.io/longguikeji/arkid:${{steps.get-versions.outputs.DEVVERSION}}" - source_username: "${{ secrets.DOCKERHUBUSERNAME }}" - source_password: "${{ secrets.DOCKERHUBPWD }}" - target_repository: "docker.io/longguikeji/arkid:${{steps.get-versions.outputs.sversion}}" - target_username: "${{ secrets.DOCKERHUBUSERNAME }}" - target_password: "${{ secrets.DOCKERHUBPWD }}" - - name: ReTag to Dockerhub 2 - uses: onichandame/docker-registry-sync-action@master - with: - source_repository: "docker.io/longguikeji/arkid:${{steps.get-versions.outputs.DEVVERSION}}" - source_username: "${{ secrets.DOCKERHUBUSERNAME }}" - source_password: "${{ secrets.DOCKERHUBPWD }}" - target_repository: "docker.io/longguikeji/arkid:2" - target_username: "${{ secrets.DOCKERHUBUSERNAME }}" - target_password: "${{ secrets.DOCKERHUBPWD }}" - - - name: ReTag to Harbor 2.x.y - uses: onichandame/docker-registry-sync-action@master + - name: Login harbor + uses: docker/login-action@v1 with: - source_repository: "docker.io/longguikeji/arkid:${{steps.get-versions.outputs.DEVVERSION}}" - source_username: "${{ secrets.DOCKERHUBUSERNAME }}" - source_password: "${{ secrets.DOCKERHUBPWD }}" - target_repository: "${{ secrets.ARK_RLS }}/arkid:${{steps.get-versions.outputs.PRODVERSION}}" - target_username: "${{ secrets.HARBORUSER }}" - target_password: "${{ secrets.HARBORPWD }}" - - name: ReTag to Harbor 2.x - uses: onichandame/docker-registry-sync-action@master + registry: harbor.longguikeji.com + username: ${{ secrets.HARBORUSER }} + password: ${{ secrets.HARBORPWD }} + - name: Login to Docker Hub + uses: docker/login-action@v1 with: - source_repository: "docker.io/longguikeji/arkid:${{steps.get-versions.outputs.DEVVERSION}}" - source_username: "${{ secrets.DOCKERHUBUSERNAME }}" - source_password: "${{ secrets.DOCKERHUBPWD }}" - target_repository: "${{ secrets.ARK_RLS }}/arkid:${{steps.get-versions.outputs.sversion}}" - target_username: "${{ secrets.HARBORUSER }}" - target_password: "${{ secrets.HARBORPWD }}" - - name: ReTag to Harbor 2 - uses: onichandame/docker-registry-sync-action@master + username: ${{ secrets.DOCKERHUBUSERNAME }} + password: ${{ secrets.DOCKERHUBPWD }} + - name: Build and push + uses: docker/build-push-action@v2 with: - source_repository: "docker.io/longguikeji/arkid:${{steps.get-versions.outputs.DEVVERSION}}" - source_username: "${{ secrets.DOCKERHUBUSERNAME }}" - source_password: "${{ secrets.DOCKERHUBPWD }}" - target_repository: "${{ secrets.ARK_RLS }}/arkid:2" - target_username: "${{ secrets.HARBORUSER }}" - target_password: "${{ secrets.HARBORPWD }}" + context: . + platforms: linux/amd64 + build-args: | + DEBIAN=http://deb.debian.org/debian + DEBIANSRT=http://security.debian.org/debian-security + PIP="https://pypi.python.org/simple" + push: true + tags: | + "docker.io/longguikeji/arkid:${{ github.ref_name}}" + "docker.io/longguikeji/arkid:${{steps.get-versions.outputs.sversion}}" + "docker.io/longguikeji/arkid:2" + "${{ secrets.ARK_RLS }}/arkid:${{ github.ref_name}}" + "${{ secrets.ARK_RLS }}/arkid:${{steps.get-versions.outputs.sversion}}" + "${{ secrets.ARK_RLS }}/arkid:2" - name: Feishu 报忧 if: ${{ failure() }} uses: wangsijie/feishu-bot@v1 with: uuid: ${{ secrets.FEISHU_UUID }} data: | - {"msg_type":"post","content":{"post":{"zh_cn":{"title":"${{ github.event.repository.name }} 镜像版本 ${{ github.event.inputs.prod_version }} 发布失败", + {"msg_type":"post","content":{"post":{"zh_cn":{"title":"${{ github.event.repository.name }} 镜像版本 ${{ github.ref_name}} 发布失败", "content":[[{"tag":"text","text":""}, {"tag":"a","text":"点击查看具体日志","href":"https://github.com/${{ github.repository }}/actions/workflows/release.yml"}]]}}}} - name: Feishu 报喜 @@ -112,6 +61,6 @@ jobs: with: uuid: ${{ secrets.FEISHU_UUID }} data: | - {"msg_type":"post","content":{"post":{"zh_cn":{"title": "${{ github.event.repository.name }} 镜像版本 ${{ github.event.inputs.prod_version }} 发布成功", + {"msg_type":"post","content":{"post":{"zh_cn":{"title": "${{ github.event.repository.name }} 镜像版本 ${{ github.ref_name}} 发布成功", "content":[[{"tag":"text","text":""}, {"tag":"a","text":"","href":"https://hub.docker.com/r/longguikeji/arkid/tags"}]]}}}} diff --git a/Dockerfile b/Dockerfile index 39b99f0c2..561454c88 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,10 +3,10 @@ EXPOSE 80 WORKDIR /var/arkid ARG DEBIAN=http://mirrors.aliyun.com/debian ARG DEBIANSRT=http://mirrors.aliyun.com/debian-security -ARG PIP="-i https://mirrors.aliyun.com/pypi/simple/" +ARG PIP="https://mirrors.aliyun.com/pypi/simple/" #ARG DEBIAN=http://deb.debian.org/debian #ARG DEBIANSRT=http://security.debian.org/debian-security -#ARG PIP="-i https://pypi.python.org/simple" +#ARG PIP="https://pypi.python.org/simple" RUN set -eux; \ sed -i 's/MinProtocol = TLSv1.2/MinProtocol = TLSv1.0/g' /etc/ssl/openssl.cnf; \ @@ -27,17 +27,7 @@ RUN set -eux; \ ADD requirements.txt ./ RUN pip install --no-cache-dir -r requirements.txt -FROM build_deps as run_lint -ADD requirements-dev.txt ./ -RUN pip install --no-cache-dir -r requirements-dev.txt ADD . . -# ARG base_commit_id="" -RUN pre-commit install \ - && .git/hooks/pre-commit - -FROM build_deps as build -ADD . . -RUN pip install mysqlclient==1.4.6 $PIP; \ - chmod +x docker-entrypoint.sh +RUN chmod +x docker-entrypoint.sh ENTRYPOINT ["/var/arkid/docker-entrypoint.sh"] CMD ["tini", "--", "/usr/local/bin/python3.8", "manage.py", "runserver", "0.0.0.0:80"]