-
Notifications
You must be signed in to change notification settings - Fork 0
149 lines (119 loc) · 3.69 KB
/
Copy pathextract.yml
File metadata and controls
149 lines (119 loc) · 3.69 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
name: Extract ZIP into Repo
on:
workflow_dispatch:
permissions:
contents: write
jobs:
extract:
runs-on: ubuntu-latest
env:
ZIP_FILE: Aria2DownloaderAndroid_daemon_fixed_idm_project.zip
steps:
- name: Checkout repo
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Ensure unzip is available
shell: bash
run: |
set -e
sudo apt-get update
sudo apt-get install -y unzip
- name: Show files before extract
shell: bash
run: |
echo "=== BEFORE ==="
find . -maxdepth 4 | sed 's#^#- #'
- name: Verify ZIP exists
shell: bash
run: |
set -e
ls -lah
test -f "$ZIP_FILE"
- name: Clean repo except .git, .github/workflows, and ZIP
shell: bash
run: |
set -e
find . -mindepth 1 -maxdepth 1 \
! -name ".git" \
! -name ".github" \
! -name "$ZIP_FILE" \
-exec rm -rf {} +
if [ -d ".github" ]; then
find .github -mindepth 1 -maxdepth 1 \
! -name "workflows" \
-exec rm -rf {} +
fi
mkdir -p .github/workflows
- name: Extract ZIP
shell: bash
run: |
set -e
mkdir -p extracted
unzip -o "$ZIP_FILE" -d extracted
echo "=== EXTRACTED STRUCTURE ==="
find extracted -maxdepth 4 | sed 's#^#- #'
- name: Find real project root
id: projectroot
shell: bash
run: |
set -e
PROJECT_DIR="$(find extracted -type f -name gradlew -exec dirname {} \; | head -n 1)"
if [ -z "$PROJECT_DIR" ]; then
PROJECT_DIR="$(find extracted -type f \( -name settings.gradle -o -name settings.gradle.kts \) -exec dirname {} \; | head -n 1)"
fi
if [ -z "$PROJECT_DIR" ]; then
echo "Could not find Android project root inside ZIP"
exit 1
fi
echo "project_dir=$PROJECT_DIR" >> "$GITHUB_OUTPUT"
echo "PROJECT_DIR=$PROJECT_DIR"
- name: Remove extracted .github so workflows stay untouched
shell: bash
run: |
set -e
PROJECT_DIR="${{ steps.projectroot.outputs.project_dir }}"
rm -rf "$PROJECT_DIR/.github"
- name: Copy extracted project into repo root
shell: bash
run: |
set -e
PROJECT_DIR="${{ steps.projectroot.outputs.project_dir }}"
cp -a "$PROJECT_DIR"/. .
- name: Delete extracted folder automatically
shell: bash
run: |
set -e
rm -rf extracted
- name: Delete ZIP after successful extraction
shell: bash
run: |
set -e
rm -f "$ZIP_FILE"
- name: Final safety check for workflows
shell: bash
run: |
set -e
mkdir -p .github/workflows
- name: Show final repo files
shell: bash
run: |
echo "=== FINAL REPO ROOT ==="
ls -lah
echo "=== gradlew path ==="
find . -maxdepth 3 -name gradlew
echo "=== .github contents ==="
find .github -maxdepth 3 | sed 's#^#- #'
- name: Commit extracted files back to repo
shell: bash
run: |
set -e
git config user.name 'github-actions[bot]'
git config user.email '41898282+github-actions[bot]@users.noreply.github.com'
git add -A
if git diff --cached --quiet; then
echo "No changes to commit"
exit 0
fi
git commit -m 'Extract project from ZIP into repo'
git push