Skip to content

Upload images 1 by 1 #23

Upload images 1 by 1

Upload images 1 by 1 #23

Workflow file for this run

name: Build Images
on:
push:
branches:
- main
jobs:
build:
runs-on: [self-hosted, ARM64, BredOS]
strategy:
fail-fast: false
matrix:
image: [nova-image, nx5-image, opi5-image, opi5plus-image, r58s-image, r58x-4g-image, r58x-image, r58x-pro-image, rock5a-image, rock5b-image, rock5c-image, cpi4-image, edge2-cinnamon-image]
steps:
- name: Checkout Images
uses: actions/checkout@v4
with:
path: images
- name: Checkout mkimage
uses: actions/checkout@v4
with:
repository: BredOS/mkimage
path: mkimage
- name: Install dependencies
run: |
sudo pacman -Sy --noconfirm --needed \
python python-prettytable parted btrfs-progs \
git wget arch-install-scripts unzip gptfdisk xz jq
- name: Build Image
run: |
sudo umount -R ./work/aarch64/* || true
sudo rm -rf /var/lib/pacman/db.lck ./out ./work
sudo python mkimage/mkimage.py -c images/${{ matrix.image }} -w ./work -o ./out
- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ matrix.image }}
path: out/*.img.xz
retention-days: 7
- name: Cleanup
if: always()
run: |
sudo umount -R ./work/aarch64/* || true
sudo rm -rf ./work ./out
release:

Check failure on line 54 in .github/workflows/build.yml

View workflow run for this annotation

GitHub Actions / Build Images

Invalid workflow file

The workflow is not valid. .github/workflows/build.yml (Line: 54, Col: 1): Unexpected value 'release'
needs: build
runs-on: [self-hosted, ARM64, BredOS, emag]
steps:
- name: Download Artifacts in Parallel
run: |
# Create the output directory
mkdir -p ./out/ && cd ./out/
# Fetch the list of artifacts using GitHub's REST API
ARTIFACTS=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/artifacts")
# Extract artifact names and IDs and download them in parallel
echo "$ARTIFACTS" | jq -r '.artifacts[] | .name + " " + (.id|tostring)' | while read -r ARTIFACT_NAME ARTIFACT_ID; do
echo "Downloading $ARTIFACT_NAME"
curl -s -L -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/actions/artifacts/$ARTIFACT_ID/zip" \
--output "$ARTIFACT_NAME.zip" &
done
# Wait for all parallel download jobs to complete
wait
# Extract artifacts
for artifact in *.zip; do
unzip -q "$artifact"
done
- name: Set current date as tag name
id: set_tag_name
run: echo "TAG_NAME=$(date +'%Y-%m-%d')" >> $GITHUB_ENV
- name: Create Release and Upload Each Image Individually
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
REPO: ${{ github.repository }}
TAG_NAME: ${{ env.TAG_NAME }}
run: |
# Create a draft release
RELEASE_RESPONSE=$(curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/json" \
-d "{\"tag_name\": \"$TAG_NAME\", \"name\": \"$TAG_NAME\", \"draft\": true, \"prerelease\": true}" \
"https://api.github.com/repos/$REPO/releases")
RELEASE_ID=$(echo $RELEASE_RESPONSE | jq -r '.id')
if [ "$RELEASE_ID" == "null" ]; then
echo "Failed to create a release. Response: $RELEASE_RESPONSE"
exit 1
fi
# Upload each image file to the release
for img in ./out/*.img.xz; do
FILENAME=$(basename "$img")
echo "Uploading $FILENAME to release $RELEASE_ID"
curl -s -X POST \
-H "Authorization: token $GITHUB_TOKEN" \
-H "Content-Type: application/octet-stream" \
--data-binary @"$img" \
"https://uploads.github.com/repos/$REPO/releases/$RELEASE_ID/assets?name=$FILENAME"
done
- name: Clean up
run: |
rm -rf ./out/