From f01845c7e15f43f0bfc6b4533b3713f29025edde Mon Sep 17 00:00:00 2001 From: luckycat0426 Date: Fri, 29 Oct 2021 09:57:02 +0800 Subject: [PATCH 1/6] update github docker build workflow MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 使用github action 自动构建docker --- .github/workflows/docker-publish.yml | 69 ++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..fedcc9e --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,69 @@ +name: Docker + +on: + push: + # Publish `main` as Docker `latest` image. + branches: + - main + + # Publish `v1.2.3` tags as releases. + tags: + - v* + + # Run tests for any PRs. + pull_request: + +env: + # TODO: Change variable to your image's name. + IMAGE_NAME: autosign + +jobs: + # Run tests. + # See also https://docs.docker.com/docker-hub/builds/automated-testing/ + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v2 + + - name: Run tests + run: | + if [ -f docker-compose.test.yml ]; then + docker-compose --file docker-compose.test.yml build + docker-compose --file docker-compose.test.yml run sut + else + docker build . --file Dockerfile + fi + # Push image to GitHub Packages. + # See also https://docs.docker.com/docker-hub/builds/ + push: + # Ensure test job passes before pushing image. + needs: test + + runs-on: ubuntu-latest + if: github.event_name == 'push' + + steps: + - uses: actions/checkout@v2 + + - name: Build image + run: docker build . --file Dockerfile --tag $IMAGE_NAME + + - name: Log into registry + run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Push image + run: | + IMAGE_ID=ghcr.io/${{ github.repository }}/$IMAGE_NAME + # Change all uppercase to lowercase + IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]') + # Strip git ref prefix from version + VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,') + # Strip "v" prefix from tag name + [[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//') + # Use Docker `latest` tag convention + [ "$VERSION" == "master" ] && VERSION=latest + echo IMAGE_ID=$IMAGE_ID + echo VERSION=$VERSION + docker tag $IMAGE_NAME $IMAGE_ID:$VERSION + docker push $IMAGE_ID:$VERSION From 05163cb8aadc2943f8cdf5a8133e651279713948 Mon Sep 17 00:00:00 2001 From: luckycat0426 Date: Fri, 29 Oct 2021 10:02:21 +0800 Subject: [PATCH 2/6] Update deploy.md --- docs/deploy.md | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/docs/deploy.md b/docs/deploy.md index f73e320..040ed3b 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -8,6 +8,11 @@ sudo docker build -t cea-check-in https://github.com/ceajs/cea.git#main:docker sudo docker run -dv /tmp/conf:/tmp/conf cea-check-in ``` + + 如果使用境内服务器,由于网络问题,构建可能失败,可以使用本仓库构建镜像 + ```bash + sudo docker run -dv /tmp/conf:/tmp/conf ghcr.io/ceajs/cea/autosign + ``` 此容器自动设置了 Cron 任务,将会在每天 6:30 触发执行签到,如需自定义触发时间,请 Fork 本仓库,修改 `docker/cea-cron`,并另行构建镜像与容器 @@ -15,7 +20,6 @@ sudo docker build -t cea-check-in Fork仓库的GitURL#main:docker sudo docker run -dv /tmp/conf:/tmp/conf cea-check-in ``` -
腾讯云开发一键部署 From 8f5047d257032736d07045b1419a635207c27e25 Mon Sep 17 00:00:00 2001 From: luckycat0426 Date: Fri, 29 Oct 2021 10:11:19 +0800 Subject: [PATCH 3/6] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index fedcc9e..83312c7 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -32,7 +32,7 @@ jobs: docker-compose --file docker-compose.test.yml build docker-compose --file docker-compose.test.yml run sut else - docker build . --file Dockerfile + docker build . --file docker/Dockerfile fi # Push image to GitHub Packages. # See also https://docs.docker.com/docker-hub/builds/ From 22a6958e6a0e78237f6c65ec827f1f477612fb6b Mon Sep 17 00:00:00 2001 From: luckycat0426 Date: Fri, 29 Oct 2021 10:20:34 +0800 Subject: [PATCH 4/6] Update docker-publish.yml --- .github/workflows/docker-publish.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 83312c7..d44dc18 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -32,7 +32,7 @@ jobs: docker-compose --file docker-compose.test.yml build docker-compose --file docker-compose.test.yml run sut else - docker build . --file docker/Dockerfile + docker build https://github.com/ceajs/cea.git#main:docker fi # Push image to GitHub Packages. # See also https://docs.docker.com/docker-hub/builds/ @@ -47,7 +47,7 @@ jobs: - uses: actions/checkout@v2 - name: Build image - run: docker build . --file Dockerfile --tag $IMAGE_NAME + run: docker build https://github.com/ceajs/cea.git#main:docker --tag $IMAGE_NAME - name: Log into registry run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin From e980617ada4938153046e0a7189d32373bb789ca Mon Sep 17 00:00:00 2001 From: beetcb <63141491+beetcb@users.noreply.github.com> Date: Fri, 29 Oct 2021 21:46:21 +0800 Subject: [PATCH 5/6] docs: follow default naming convention --- .github/workflows/docker-publish.yml | 2 +- docs/deploy.md | 25 ++++++++++++++++++------- 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index d44dc18..383dbda 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -15,7 +15,7 @@ on: env: # TODO: Change variable to your image's name. - IMAGE_NAME: autosign + IMAGE_NAME: cea-check-in jobs: # Run tests. diff --git a/docs/deploy.md b/docs/deploy.md index 040ed3b..703ffaf 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -5,22 +5,33 @@ 2. 构建 Image 并运行 Container ```bash + # 在本地构建 Image sudo docker build -t cea-check-in https://github.com/ceajs/cea.git#main:docker - sudo docker run -dv /tmp/conf:/tmp/conf cea-check-in + + # 创建容器 + sudo docker run --name auto-check-in -dv /tmp/conf:/tmp/conf cea-check-in ``` - - 如果使用境内服务器,由于网络问题,构建可能失败,可以使用本仓库构建镜像 + + 如果使用境内服务器,由于网络问题,构建可能失败,可以使用本仓库已经构建完成的镜像 + ```bash - sudo docker run -dv /tmp/conf:/tmp/conf ghcr.io/ceajs/cea/autosign + sudo docker run --name auto-check-in -dv /tmp/conf:/tmp/conf ghcr.io/ceajs/cea/cea-check-in ``` - 此容器自动设置了 Cron 任务,将会在每天 6:30 触发执行签到,如需自定义触发时间,请 Fork 本仓库,修改 `docker/cea-cron`,并另行构建镜像与容器 + 此容器自动设置了 Cron 任务,将会在每天 6:30 触发执行签到,如需自定义触发时间,请 Fork 本仓库(或者 Clone 本仓库),修改 `docker/cea-cron`,并另行构建镜像与容器 ``` + # 如果你是 Fork 并 Push 了修改 sudo docker build -t cea-check-in Fork仓库的GitURL#main:docker - sudo docker run -dv /tmp/conf:/tmp/conf cea-check-in + + # 如果你是 Clone 并在本地修改,请进入 docker 文件夹 + sudo docker build -t cea-check-in . + + # 创建容器 + sudo docker run --name auto-check-in -dv /tmp/conf:/tmp/conf cea-check-in ``` -
+ +
腾讯云开发一键部署 From d28358f6a931da38356017b1ab164f14dd3c23d1 Mon Sep 17 00:00:00 2001 From: beetcb <63141491+beetcb@users.noreply.github.com> Date: Fri, 29 Oct 2021 22:38:18 +0800 Subject: [PATCH 6/6] docs(deploy): fix url typo --- docs/deploy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deploy.md b/docs/deploy.md index 703ffaf..1d04afa 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -15,7 +15,7 @@ 如果使用境内服务器,由于网络问题,构建可能失败,可以使用本仓库已经构建完成的镜像 ```bash - sudo docker run --name auto-check-in -dv /tmp/conf:/tmp/conf ghcr.io/ceajs/cea/cea-check-in + sudo docker run --name auto-check-in -dv /tmp/conf:/tmp/conf ghcr.io/ceajs/cea/cea-check-in:main ``` 此容器自动设置了 Cron 任务,将会在每天 6:30 触发执行签到,如需自定义触发时间,请 Fork 本仓库(或者 Clone 本仓库),修改 `docker/cea-cron`,并另行构建镜像与容器