Skip to content

Commit

Permalink
Merge pull request #788 from longguikeji/v2-dev
Browse files Browse the repository at this point in the history
feat: 优化镜像,优化发版action
  • Loading branch information
notevery committed Apr 22, 2022
2 parents e037042 + b668261 commit 0082fca
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 97 deletions.
117 changes: 33 additions & 84 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -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 报喜
Expand All @@ -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"}]]}}}}
16 changes: 3 additions & 13 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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; \
Expand All @@ -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"]

0 comments on commit 0082fca

Please sign in to comment.