13 Commits

Author SHA1 Message Date
6ca5f9aef2 feat: 恢复 docker-build-push.yml 中的分支和路径配置 2024-10-10 11:14:57 +08:00
746c056e16 feat: 在 docker-build-push.yml 中新增 pull_request 触发器 2024-10-10 11:05:20 +08:00
bf2f20471c chore: 注释掉 docker-build-push.yml 中的分支和路径配置 2024-10-10 11:01:22 +08:00
5bd89bc7bb Create README.md 2024-10-09 14:34:11 +08:00
ad1ed515d9 feat: 更新 docker-build-push.yml,启用 GitHub Container Registry 登录步骤 2024-10-09 12:26:04 +08:00
2e7fd5567e feat: 重构 CI 流程,新增 docker-build-push 工作流
Some checks failed
持续集成 / setup-node-environment-test (push) Successful in 19s
docker-build-push / docker-build-push-test (push) Failing after 52s
2024-10-09 12:17:23 +08:00
ebb6f5dc6c feat: 测试 semantic 2024-10-09 11:57:19 +08:00
da7c4ac612 feat: 添加检查 .git 文件夹的步骤 2024-10-09 11:46:38 +08:00
aca6c13ecb fix: 修复 docker-build-push action.yml 中的 context 配置 2024-10-09 11:34:13 +08:00
a6b302e68a feat: 测试 semantic-release-action 2024-10-09 11:31:41 +08:00
dd22eed198 测试 Check .git folder 2024-10-09 11:27:20 +08:00
3624aae550 测试 metadata_tags 2024-10-09 11:09:53 +08:00
f622e0b7fa 测试 metadata_tags 2024-10-09 11:07:08 +08:00
6 changed files with 89 additions and 36 deletions

View File

@ -2,6 +2,8 @@ name: 持续集成
on:
push:
branches:
- main
env:
TZ: Asia/Shanghai
@ -15,39 +17,3 @@ jobs:
run: |
set -x
which pnpm
docker-build-push-test:
runs-on: ubuntu-latest
steps:
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: yanhao98/composite-actions/docker-build-push@main
id: docker-build-push
with:
build_file: ./docker-build-push/Dockerfile
build_platforms: linux/amd64
build_push: ${{ github.ref_type == 'tag' }}
build_load: true
metadata_images: |
docker.io/${{ vars.DOCKERHUB_USERNAME }}/docker-example
ghcr.io/${{ github.repository }}
metadata_tags: |
type=semver,pattern={{version}}
type=semver,pattern={{major}}.{{minor}}
type=semver,pattern={{major}}
- name: Check Docker image
run: |
set -x;
docker images;
docker run --rm ${{ steps.docker-build-push.outputs.imageid }} whoami;

55
.github/workflows/docker-build-push.yml vendored Normal file
View File

@ -0,0 +1,55 @@
name: docker-build-push
on:
push:
branches:
- main
paths:
- 'docker-build-push/**'
- '.github/workflows/docker-build-push.yml'
env:
TZ: Asia/Shanghai
jobs:
docker-build-push-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@main
- uses: yanhao98/semantic-release-action@main
id: semantic
- name: Login to Docker Hub
if: steps.semantic.outputs.next_release_published == 'true'
uses: docker/login-action@v3
with:
username: ${{ vars.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Login to GitHub Container Registry
if: steps.semantic.outputs.next_release_published == 'true'
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: yanhao98/composite-actions/docker-build-push@main
if: steps.semantic.outputs.next_release_published == 'true'
id: docker-build-push
with:
build_file: ./docker-build-push/Dockerfile
build_platforms: linux/amd64,linux/arm64
build_push: true
build_load: false
metadata_images: |
docker.io/${{ vars.DOCKERHUB_USERNAME }}/docker-example
ghcr.io/${{ github.repository }}
metadata_tags: |
type=semver,pattern={{version}},value=${{ steps.semantic.outputs.next_release_version }}
type=semver,pattern={{major}}.{{minor}},value=${{ steps.semantic.outputs.next_release_version }}
type=semver,pattern={{major}},value=${{ steps.semantic.outputs.next_release_version }}
# - name: Check Docker image
# run: |
# set -x;
# docker images;
# docker run --rm ${{ steps.docker-build-push.outputs.imageid }} whoami;

7
.releaserc.json Normal file
View File

@ -0,0 +1,7 @@
{
"plugins": [
"@semantic-release/commit-analyzer",
"@semantic-release/release-notes-generator",
"@semantic-release/changelog"
]
}

1
README.md Normal file
View File

@ -0,0 +1 @@
- https://github.com/renovatebot/renovate/blob/81fc75630b0b43fb4b89a0b65c1086d487e65d2e/.github/actions/setup-node/action.yml

View File

@ -33,7 +33,19 @@ outputs:
runs:
using: "composite"
steps:
- name: Check .git folder
id: check-git-folder
shell: bash
run: |
if [ -d .git ]; then
echo "Found .git folder"
echo "git-folder-exists=true" >> $GITHUB_OUTPUT
else
echo "No .git folder found"
echo "git-folder-exists=false" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@main
if: steps.check-git-folder.outputs.git-folder-exists == 'false'
with:
filter: blob:none
show-progress: false

View File

@ -16,7 +16,19 @@ description: "Setup pnpm + Node.js + install dependencies"
runs:
using: "composite"
steps:
- name: Check .git folder
id: check-git-folder
shell: bash
run: |
if [ -d .git ]; then
echo "Found .git folder"
echo "git-folder-exists=true" >> $GITHUB_OUTPUT
else
echo "No .git folder found"
echo "git-folder-exists=false" >> $GITHUB_OUTPUT
fi
- uses: actions/checkout@main
if: steps.check-git-folder.outputs.git-folder-exists == 'false'
with:
# fetch-depth: 0 # zero stands for full checkout, which is required for semantic-release
filter: blob:none # we don't need all blobs, only the full tree