fix workflow #57
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: Build and Push Images | ||
|
Check failure on line 1 in .github/workflows/build_and_push_images.yaml
|
||
| on: | ||
| push: | ||
| branches: | ||
| - "main" | ||
| paths-ignore: | ||
| - "**/*.png" | ||
| pull_request: | ||
| branches: | ||
| - "main" | ||
| paths-ignore: | ||
| - "**/*.png" | ||
| jobs: | ||
| publish: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v3 | ||
| # build and push image | ||
| - name: Login to DockerHub | ||
| if: github.event_name == 'push' | ||
| uses: docker/login-action@v2 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | ||
| - name: Build and Push Commit Image | ||
| if: github.event_name == 'push' | ||
| run: sh push-images.sh | ||
| # 第二个 job:列出文件并上传为独立 artifacts | ||
| upload-separately: | ||
| needs: build | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/download-artifact@v4 | ||
| with: | ||
| name: images-tarballs | ||
| path: . | ||
| - name: List .tar.gz files | ||
| id: list_files | ||
| run: | | ||
| files=(*.tar.gz) | ||
| if [ "${files[0]}" = "*.tar.gz" ]; then | ||
| echo "files_json=[]" >> $GITHUB_OUTPUT | ||
| else | ||
| printf '%s\n' "${files[@]}" | jq -R . | jq -s '.' >> $GITHUB_OUTPUT | ||
| echo "files_json=$(printf '%s\n' "${files[@]}" | jq -R . | jq -s .)" >> $GITHUB_OUTPUT | ||
| fi | ||
| # ✅ matrix 必须在 job 层 | ||
| strategy: | ||
| matrix: | ||
| filename: ${{ fromJson(steps.list_files.outputs.files_json) }} | ||
| steps: | ||
| - name: Set up | ||
| run: echo "Uploading ${{ matrix.filename }}" | ||
| - name: Upload each .tar.gz as separate artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: ${{ matrix.filename }} | ||
| path: ${{ matrix.filename }} | ||