v1.1.0 #4
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # 工作流名称 | |
| name: Docker Image Build | |
| # 触发方式: | |
| # - Release触发: 当创建或更新 Release 时自动触发构建 | |
| # - 手动触发: 可以通过 GitHub Actions 页面手动触发 | |
| on: | |
| release: | |
| types: [published] | |
| workflow_dispatch: | |
| inputs: | |
| version: | |
| description: "Image tag to build, for example v1.0.0" | |
| required: false | |
| # 构建任务 | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| # 检出代码 | |
| - name: 检出代码 | |
| uses: actions/checkout@v3 | |
| with: | |
| fetch-depth: 0 | |
| # 获取版本号 | |
| - name: 获取版本号 | |
| id: get_version | |
| run: | | |
| RELEASE_TAG="${{ github.event.release.tag_name }}" | |
| INPUT_VERSION="${{ github.event.inputs.version }}" | |
| if [ -n "$RELEASE_TAG" ]; then | |
| VERSION="$RELEASE_TAG" | |
| elif [ -n "$INPUT_VERSION" ]; then | |
| VERSION="$INPUT_VERSION" | |
| else | |
| VERSION=$(git describe --tags --abbrev=0 2>/dev/null || echo 'latest') | |
| fi | |
| echo "VERSION=$VERSION" >> $GITHUB_ENV | |
| # 添加仓库名小写转换 | |
| echo "OWNER_LC=${GITHUB_REPOSITORY_OWNER,,}" >> $GITHUB_ENV | |
| # 登录各个镜像仓库 | |
| - name: 登录镜像仓库 | |
| run: | | |
| echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin | |
| echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.repository_owner }} --password-stdin | |
| echo "${{ secrets.IMAGE_PASS }}" | docker login registry.cn-hangzhou.aliyuncs.com -u ${{ secrets.IMAGE_USER }} --password-stdin | |
| # 设置 Docker Buildx | |
| - name: 设置 Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| # 构建并推送到 DockerHub 和 GitHub | |
| - name: 构建并推送到 GitHub/DockerHub | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| platforms: linux/amd64,linux/arm64 | |
| push: true | |
| tags: | | |
| thingspanel/thingspanel-adapter-http:${{ env.VERSION }} | |
| ghcr.io/${{ env.OWNER_LC }}/thingspanel-adapter-http:${{ env.VERSION }} | |
| registry.cn-hangzhou.aliyuncs.com/thingspanel/thingspanel-adapter-http:${{ env.VERSION }} |