| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144 |
- name: Download Artifacts from Run
- on:
- workflow_dispatch:
- inputs:
- run_id:
- description: 'GitHub Actions Run ID to download artifacts from'
- required: true
- type: string
- release_tag:
- description: 'Release tag to upload to'
- required: true
- type: string
- jobs:
- download-and-upload:
- runs-on: ubuntu-latest
-
- env:
- GH_TOKEN: ${{ github.token }}
-
- steps:
- - name: Checkout repository
- uses: actions/checkout@v4
- - name: Set target release tag
- id: get_release
- run: |
- echo "tag=${{ inputs.release_tag }}" >> $GITHUB_OUTPUT
- echo "Using release tag: ${{ inputs.release_tag }}"
-
- # Verify the release exists
- if ! gh release view "${{ inputs.release_tag }}" >/dev/null 2>&1; then
- echo "Error: Release '${{ inputs.release_tag }}' does not exist"
- echo "Available releases:"
- gh release list --limit 10
- exit 1
- fi
-
- echo "Release '${{ inputs.release_tag }}' found and verified"
- - name: Download AnyKernel3 artifacts from specified run
- run: |
- echo "Downloading AnyKernel3 artifacts from run ID: ${{ inputs.run_id }}"
-
- # Create directory for downloaded artifacts
- mkdir -p ./downloaded-artifacts
-
- # Get list of all artifacts from the run
- echo "Getting artifact list from run..."
- gh api repos/${{ github.repository }}/actions/runs/${{ inputs.run_id }}/artifacts --jq '.artifacts[] | select(.name | endswith("-AnyKernel3")) | {name: .name, id: .id}' > artifacts.json
-
- # Check if any AnyKernel3 artifacts were found
- if [ ! -s artifacts.json ]; then
- echo "Error: No AnyKernel3 artifacts found in run ${{ inputs.run_id }}"
- echo "Available artifacts in this run:"
- gh api repos/${{ github.repository }}/actions/runs/${{ inputs.run_id }}/artifacts --jq '.artifacts[].name'
- exit 1
- fi
-
- echo "Found AnyKernel3 artifacts:"
- cat artifacts.json
-
- # Download only the AnyKernel3 artifacts
- while IFS= read -r artifact; do
- artifact_name=$(echo "$artifact" | jq -r '.name')
- artifact_id=$(echo "$artifact" | jq -r '.id')
- echo "Downloading artifact: $artifact_name (ID: $artifact_id)"
- gh api repos/${{ github.repository }}/actions/artifacts/$artifact_id/zip > "${artifact_name}.zip"
-
- # Extract the artifact
- unzip -q "${artifact_name}.zip" -d "./downloaded-artifacts/${artifact_name}/"
- rm "${artifact_name}.zip"
- done < <(jq -c '.' artifacts.json)
-
- echo "Downloaded AnyKernel3 artifacts:"
- ls -la ./downloaded-artifacts/
- - name: Prepare and upload AnyKernel3 artifacts to release
- run: |
- echo "Preparing AnyKernel3 artifacts for upload..."
-
- # Check if we have any downloaded artifacts
- if [ ! -d "./downloaded-artifacts" ] || [ -z "$(ls -A ./downloaded-artifacts)" ]; then
- echo "Error: No artifacts were downloaded"
- exit 1
- fi
-
- # Process each AnyKernel3 artifact directory
- for artifact_dir in ./downloaded-artifacts/*/; do
- if [ -d "$artifact_dir" ]; then
- # Get the artifact name (remove path and trailing slash)
- artifact_name=$(basename "$artifact_dir")
-
- echo "Processing artifact: $artifact_name"
-
- # Create ZIP file with the artifact name
- # The ZIP will contain all subfolders and subfiles from the artifact
- cd "$artifact_dir"
- zip -r "../../${artifact_name}.zip" . -x "*.git*"
- cd - > /dev/null
-
- echo "Created ZIP: ${artifact_name}.zip"
-
- # Upload to release
- echo "Uploading ${artifact_name}.zip to release ${{ steps.get_release.outputs.tag }}..."
- gh release upload "${{ steps.get_release.outputs.tag }}" "${artifact_name}.zip" --clobber --repo ${{ github.repository }}
-
- echo "Successfully uploaded: ${artifact_name}.zip"
- fi
- done
-
- echo "All AnyKernel3 artifacts have been processed and uploaded!"
-
- # Show final summary
- echo "## Upload Summary" >> $GITHUB_STEP_SUMMARY
- echo "| Artifact | Status |" >> $GITHUB_STEP_SUMMARY
- echo "|----------|--------|" >> $GITHUB_STEP_SUMMARY
-
- for artifact_dir in ./downloaded-artifacts/*/; do
- if [ -d "$artifact_dir" ]; then
- artifact_name=$(basename "$artifact_dir")
- echo "| ${artifact_name}.zip | ✅ Uploaded |" >> $GITHUB_STEP_SUMMARY
- fi
- done
- - name: Summary
- run: |
- echo "## Artifact Download and Upload Summary" >> $GITHUB_STEP_SUMMARY
- echo "- **Source Run ID**: ${{ inputs.run_id }}" >> $GITHUB_STEP_SUMMARY
- echo "- **Target Release**: ${{ env.RELEASE_TAG }}" >> $GITHUB_STEP_SUMMARY
- echo "- **Repository**: ${{ github.repository }}" >> $GITHUB_STEP_SUMMARY
- echo "" >> $GITHUB_STEP_SUMMARY
- echo "### Artifacts Processed" >> $GITHUB_STEP_SUMMARY
-
- for dir in ./downloaded-artifacts/*/; do
- if [[ "$(basename "$dir")" == *"-AnyKernel3" ]]; then
- artifact_name=$(basename "$dir")
- echo "- ✅ $artifact_name" >> $GITHUB_STEP_SUMMARY
- fi
- done
-
- echo "" >> $GITHUB_STEP_SUMMARY
- echo "[🔗 View Release](${{ github.server_url }}/${{ github.repository }}/releases/tag/${{ env.RELEASE_TAG }})" >> $GITHUB_STEP_SUMMARY
|