Skip to content

Commit 04371c3

Browse files
authored
Merge pull request #6 from thenot-lab/copilot/fix-github-actions-workflow
Add workflow permissions, standardize outputs, and implement PR-based scaffolding
2 parents 03cd0a3 + e33a7be commit 04371c3

File tree

2 files changed

+57
-2
lines changed

2 files changed

+57
-2
lines changed

.github/workflows/scaffold-build-release.yml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ on:
55
push:
66
branches: [ main ]
77

8+
permissions:
9+
contents: write
10+
id-token: write
11+
actions: read
12+
813
jobs:
914
scaffold-build-release:
1015
runs-on: ubuntu-latest
@@ -80,21 +85,61 @@ jobs:
8085
REQ
8186
mkdir -p assets/fonts assets/themes src/ui src/copilot src/auth src/filesystem src/executor
8287
echo "Replace with real PNG" > assets/placeholder_icon.txt
88+
89+
# Create a new branch for scaffolded changes
90+
BRANCH_NAME="scaffold/auto-generated-$(date +%Y%m%d-%H%M%S)"
8391
git config user.name "github-actions[bot]"
8492
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
93+
git checkout -b "$BRANCH_NAME"
8594
git add main.py buildozer.spec requirements.txt assets || true
8695
git commit -m "scaffold: add minimal Kivy app and buildozer.spec" || true
87-
echo "Scaffolded=1" >> $GITHUB_OUTPUT
96+
97+
# Push branch with error handling
98+
if git push origin "$BRANCH_NAME"; then
99+
echo "Successfully pushed branch $BRANCH_NAME"
100+
# Save branch name for PR creation
101+
echo "branch_name=$BRANCH_NAME" >> $GITHUB_OUTPUT
102+
echo "scaffolded=1" >> $GITHUB_OUTPUT
103+
else
104+
echo "Failed to push branch. Scaffolding aborted."
105+
exit 1
106+
fi
88107
else
89-
echo "Scaffolded=0" >> $GITHUB_OUTPUT
108+
echo "scaffolded=0" >> $GITHUB_OUTPUT
90109
fi
91110
111+
- name: Create Pull Request for scaffolded files
112+
if: steps.scaffold.outputs.scaffolded == '1'
113+
env:
114+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
115+
run: |
116+
cat > ${{ runner.temp }}/pr_body.md <<'EOFBODY'
117+
This PR was automatically created by the scaffold workflow.
118+
119+
## Changes
120+
- Added main.py with minimal Kivy app structure
121+
- Added buildozer.spec for Android build configuration
122+
- Added requirements.txt with Python dependencies
123+
- Created initial directory structure for assets and source code
124+
125+
Please review and merge to proceed with the build process.
126+
EOFBODY
127+
gh pr create \
128+
--title "Auto-scaffold: Add minimal Kivy app and buildozer config" \
129+
--body-file ${{ runner.temp }}/pr_body.md \
130+
--label "automated" \
131+
--label "scaffold" \
132+
--head "${{ steps.scaffold.outputs.branch_name }}" \
133+
--base main
134+
92135
- name: Install OS packages
136+
if: steps.scaffold.outputs.scaffolded != '1'
93137
run: |
94138
sudo apt-get update -y
95139
sudo apt-get install -y openjdk-11-jdk unzip wget libc6-i386 lib32stdc++6 lib32gcc1
96140
97141
- name: Install Android tools & SDK packages
142+
if: steps.scaffold.outputs.scaffolded != '1'
98143
run: |
99144
set -e
100145
mkdir -p "$ANDROID_SDK_ROOT/cmdline-tools"
@@ -108,34 +153,40 @@ jobs:
108153
echo "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin" >> $GITHUB_PATH
109154
110155
- name: Accept Android SDK licenses
156+
if: steps.scaffold.outputs.scaffolded != '1'
111157
run: |
112158
yes | "$ANDROID_SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" --licenses || true
113159
114160
- name: Setup Python
161+
if: steps.scaffold.outputs.scaffolded != '1'
115162
uses: actions/setup-python@v4
116163
with:
117164
python-version: '3.9'
118165

119166
- name: Install Buildozer, Cython and requirements
167+
if: steps.scaffold.outputs.scaffolded != '1'
120168
run: |
121169
python -m pip install --upgrade pip wheel setuptools
122170
pip install buildozer==1.4.2 cython==0.29.36
123171
pip install -r requirements.txt || true
124172
125173
- name: Build APK with Buildozer
174+
if: steps.scaffold.outputs.scaffolded != '1'
126175
run: |
127176
set -e
128177
buildozer android clean || true
129178
buildozer -v android debug
130179
ls -la bin || true
131180
132181
- name: Upload APK artifact
182+
if: steps.scaffold.outputs.scaffolded != '1'
133183
uses: actions/upload-artifact@v3
134184
with:
135185
name: mobileide-apk
136186
path: bin/*.apk
137187

138188
- name: Create Release and upload APK
189+
if: steps.scaffold.outputs.scaffolded != '1'
139190
uses: softprops/action-gh-release@v1
140191
with:
141192
files: bin/*.apk
@@ -145,6 +196,7 @@ jobs:
145196
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
146197

147198
- name: Output install link
199+
if: steps.scaffold.outputs.scaffolded != '1'
148200
run: |
149201
APK_FILE=$(basename bin/*.apk)
150202
INSTALL_URL="https://github.com/${GITHUB_REPOSITORY}/releases/latest/download/${APK_FILE}"

BUILD_AND_RELEASE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ Save as BUILD_AND_RELEASE.md in the repo root (or paste into an agent). This sin
1818
## 3) Minimal/Scaffold GitHub Actions workflow
1919
- Create .github/workflows/scaffold-build-release.yml with the exact contents below. This workflow will:
2020
- Scaffold a minimal Kivy app if main.py/buildozer.spec missing
21+
- Create a pull request with the scaffolded files (does NOT push directly to main)
22+
- After PR is merged, subsequent runs will build the APK
2123
- Install Android SDK tools, Buildozer, build the APK
2224
- Create a GitHub Release and upload the APK
2325
- Emit a direct download URL for the APK
@@ -30,6 +32,7 @@ See `.github/workflows/scaffold-build-release.yml` for the complete workflow.
3032
git add . && git commit -m "Add workflow" && git push origin main
3133
```
3234
- Or run Actions → Scaffold, Build & Release APK → Run workflow (workflow_dispatch).
35+
- **Note**: If the workflow needs to scaffold files (first run), it will create a pull request instead of building immediately. Review and merge the PR, then trigger the workflow again to build the APK.
3336

3437
## 5) After the workflow completes
3538
- Open the workflow run; view step "Output install link" or check the job summary for:

0 commit comments

Comments
 (0)