Repository navigation
build(deps): bump actions/checkout from 4 to 7 #27
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 镜像构建' | |
| on: | |
| workflow_dispatch: | |
| pull_request: | |
| push: | |
| branches: | |
| - main | |
| tags: | |
| - 'v*' # 打 v0.1.0 等标签时自动构建并产出镜像 | |
| release: | |
| types: [published, released] | |
| permissions: | |
| contents: write | |
| jobs: | |
| docker-build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v7 | |
| - name: 'Go 单元测试' | |
| uses: actions/setup-go@v7 | |
| with: | |
| go-version: '1.26' | |
| - name: '运行测试' | |
| run: go test ./... | |
| - name: '构建 Docker 镜像' | |
| run: | | |
| docker build -t simplewebshell-remoteupdate . | |
| - name: '导出并上传镜像工件' | |
| run: | | |
| docker save simplewebshell-remoteupdate | gzip > simplewebshell-remoteupdate-image.tar.gz | |
| # PR 的 ref_name 形如 15/merge,dependabot 分支名也含斜杠, | |
| # 而 upload-artifact 的工件名不允许出现 /,这里统一替换为连字符。 | |
| - name: '计算工件名' | |
| shell: bash | |
| run: echo "ARTIFACT_NAME=simplewebshell-remoteupdate-docker-image-${GITHUB_REF_NAME//\//-}" >> "$GITHUB_ENV" | |
| - uses: actions/upload-artifact@v7 | |
| with: | |
| name: ${{ env.ARTIFACT_NAME }} | |
| path: 'simplewebshell-remoteupdate-image.tar.gz' | |
| if-no-files-found: 'warn' | |
| retention-days: 14 | |
| - name: '上传镜像包到 Release' | |
| if: github.event_name == 'release' || startsWith(github.ref, 'refs/tags/v') | |
| uses: softprops/action-gh-release@v3 | |
| with: | |
| tag_name: ${{ github.event.release.tag_name || github.ref_name }} | |
| files: 'simplewebshell-remoteupdate-image.tar.gz' | |
| fail_on_unmatched_files: false |