From 709849e048494de1f545a5287fa3e8a1537aacfe Mon Sep 17 00:00:00 2001 From: jaywcjlove <398188662@qq.com> Date: Fri, 2 Sep 2022 01:46:24 +0800 Subject: [PATCH] feat: support docker deplay. --- .github/workflows/ci.yml | 72 ++++++++++++++++++++++++++++++++++++++-- Dockerfile | 7 ++++ README.md | 36 ++++++++++++++++++++ 3 files changed, 113 insertions(+), 2 deletions(-) create mode 100644 Dockerfile diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3d174ef..0e613f1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -23,9 +23,77 @@ jobs: output: build/CONTRIBUTORS.svg avatarSize: 42 + - name: Create Tag + id: create_tag + uses: jaywcjlove/create-tag-action@main + with: + package-path: ./package.json + + - name: get tag version + id: tag_version + uses: jaywcjlove/changelog-generator@main + - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: - commit_message: ${{ github.event.head_commit.message }} + commit_message: ${{ github.event.head_commit.message }} ${{steps.tag_version.outputs.tag}} github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./build \ No newline at end of file + publish_dir: ./build + + - name: Generate Changelog + id: changelog + uses: jaywcjlove/changelog-generator@main + with: + head-ref: ${{steps.create_tag.outputs.version}} + filter-author: (renovate-bot|Renovate Bot) + filter: '[R|r]elease[d]\s+[v|V]\d(\.\d+){0,2}' + + - name: Create Release + uses: ncipollo/release-action@v1 + if: steps.create_tag.outputs.successful + with: + token: ${{ secrets.GITHUB_TOKEN }} + name: ${{ steps.create_tag.outputs.version }} + tag: ${{ steps.create_tag.outputs.version }} + body: | + Documentation ${{ steps.changelog.outputs.tag }}: https://raw.githack.com/jaywcjlove/wxmp/${{ steps.changelog.outputs.gh-pages-short-hash }}/index.html + Comparing Changes: ${{ steps.changelog.outputs.compareurl }} + + ${{ steps.changelog.outputs.changelog }} + + # Create Docker Image + - name: Docker login + run: docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }} + + - name: Build Awesome Mac image + run: docker image build -t wxmp . + + - name: Tags & Push image (latest) + run: | + echo "outputs.tag - ${{ steps.changelog.outputs.version }}" + docker tag wxmp ${{ secrets.DOCKER_USER }}/wxmp:latest + docker push ${{ secrets.DOCKER_USER }}/wxmp:latest + + - name: Tags & Push image + if: steps.create_tag.outputs.successful + run: | + echo "outputs.tag - ${{ steps.changelog.outputs.version }}" + docker tag wxmp ${{ secrets.DOCKER_USER }}/wxmp:${{steps.changelog.outputs.version}} + docker push ${{ secrets.DOCKER_USER }}/wxmp:${{steps.changelog.outputs.version}} + + # Create Docker Image in GitHub + - name: Login to GitHub registry + run: echo ${{ github.token }} | docker login ghcr.io -u ${{ github.actor }} --password-stdin + + - name: Build docker image + run: docker build -t ghcr.io/jaywcjlove/wxmp:latest . + + - name: Publish to GitHub registry + run: docker push ghcr.io/jaywcjlove/wxmp:latest + + - name: Tag docker image (beta) and publish to GitHub registry + if: steps.create_tag.outputs.successful + run: | + echo "version: v${{ steps.changelog.outputs.version }}" + docker tag ghcr.io/jaywcjlove/wxmp:latest ghcr.io/jaywcjlove/wxmp:${{steps.changelog.outputs.version}} + docker push ghcr.io/jaywcjlove/wxmp:${{steps.changelog.outputs.version}} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..7719b22 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,7 @@ +# https://lipanski.com/posts/smallest-docker-image-static-website +# https://github.com/lipanski/docker-static-website +FROM lipanski/docker-static-website:latest + +# Copy the static website +# Use the .dockerignore file to control what ends up inside the image! +COPY ./build . \ No newline at end of file diff --git a/README.md b/README.md index f1f6420..582ac9a 100644 --- a/README.md +++ b/README.md @@ -72,6 +72,42 @@ Inline Code `{code: 0}` 音 yin +## 部署 + +[![Docker Image Version (latest by date)](https://img.shields.io/docker/v/wcjiang/wxmp?logo=docker)](https://hub.docker.com/r/wcjiang/wxmp) [![Docker Image Size (latest by date)](https://img.shields.io/docker/image-size/wcjiang/wxmp?logo=docker)](https://hub.docker.com/r/wcjiang/wxmp) [![Docker Pulls](https://img.shields.io/docker/pulls/wcjiang/wxmp?logo=docker)](https://hub.docker.com/r/wcjiang/wxmp) + +轻松通过 docker 部署《微信公众号 Markdown 编辑器》网站应用。 + +```bash +docker pull wcjiang/wxmp +# Or +docker pull ghcr.io/jaywcjlove/wxmp:latest +``` + +```bash +docker run --name wxmp --rm -d -p 96611:3000 wcjiang/wxmp:latest +# Or +docker run --name wxmp -itd -p 96611:3000 wcjiang/wxmp:latest +# Or +docker run --name wxmp -itd -p 96611:3000 ghcr.io/jaywcjlove/wxmp:latest +``` + +在浏览器中访问以下 URL + +``` +http://localhost:96611/ +``` + +## Contributors + +As always, thanks to our amazing contributors! + + + + + +Made with [github-action-contributors](https://github.com/jaywcjlove/github-action-contributors). + ## License Licensed under the MIT License.