Skip to content

fix workflow

fix workflow #57

name: Build and Push Images

Check failure on line 1 in .github/workflows/build_and_push_images.yaml

View workflow run for this annotation

GitHub Actions / .github/workflows/build_and_push_images.yaml

Invalid workflow file

(Line: 54, Col: 19): Unrecognized named-value: 'steps'. Located at position 10 within expression: fromJson(steps.list_files.outputs.files_json), (Line: 54, Col: 19): Unexpected value '${{ fromJson(steps.list_files.outputs.files_json) }}', (Line: 56, Col: 5): 'steps' is already defined
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 }}