Compare commits
35 Commits
0b27af0440
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 559ccca3f8 | |||
| bb4c82c8c6 | |||
| df1aa85151 | |||
| e3c125f99d | |||
| 284d715aa3 | |||
| dc9c2f6c4d | |||
| a08c3fc1fa | |||
| cad0a686c0 | |||
| fcb18d7fe3 | |||
| 8036b76f05 | |||
| ee20210c7b | |||
| b7b304b4fd | |||
| 74a631643b | |||
| 7e134c7a1c | |||
| 3b5b3414fc | |||
| b35dd1f5d4 | |||
| 928b88887d | |||
| ed728e7028 | |||
| 12787d8daf | |||
| da192e0228 | |||
| c6c2069195 | |||
| c685c9b519 | |||
| c9055bbd25 | |||
| e8c01c8747 | |||
| edcb1adef0 | |||
| b8fd333f04 | |||
| e19ddeaa67 | |||
| bc5df5f05c | |||
| 9fa2e39f7c | |||
| 052156cc43 | |||
| eff0142a22 | |||
| db2871fb5d | |||
| 9bb593ec3a | |||
| 6ba8ca0357 | |||
| 29b4ffe576 |
@@ -40,7 +40,8 @@ jobs:
|
||||
# Move file if it's not already in the correct location
|
||||
if [ "$src" != "$dest" ] && [ -f "$src" ]; then
|
||||
echo "Moving: $src -> $dest"
|
||||
mv "$src" "$dest"
|
||||
# Use git mv to preserve git tracking
|
||||
git mv "$src" "$dest"
|
||||
return 0 # Success - file was moved
|
||||
fi
|
||||
return 1 # No file moved
|
||||
@@ -80,19 +81,7 @@ jobs:
|
||||
fi
|
||||
id: sort_files
|
||||
|
||||
- name: Commit moved files
|
||||
if: steps.sort_files.outputs.files_moved == 'true'
|
||||
run: |
|
||||
git config --local user.email "ci-bot@b4l.co.th"
|
||||
git config --local user.name "B4L CI Auto-Sort Bot"
|
||||
git add docs/datasheets/ docs/images/
|
||||
git commit -m "Auto-sort: Move DS_ and IMG_ prefixed files to correct directories
|
||||
|
||||
- Moved datasheet files (DS_*) to docs/datasheets/
|
||||
- Moved image files (IMG_*) to docs/images/
|
||||
- Automated by Gitea Actions auto-sort workflow"
|
||||
|
||||
- name: Push changes
|
||||
- name: Commit and push moved files
|
||||
if: steps.sort_files.outputs.files_moved == 'true'
|
||||
run: |
|
||||
# Get the repository URL dynamically
|
||||
@@ -103,34 +92,44 @@ jobs:
|
||||
# HTTPS URL format: https://git.b4l.co.th/B4L/repo-name.git
|
||||
DOMAIN=$(echo $REPO_URL | sed 's|https://\([^/]*\)/.*|\1|')
|
||||
REPO_PATH=$(echo $REPO_URL | sed 's|https://[^/]*/\(.*\)|\1|')
|
||||
PUSH_URL="https://ci-bot:${{ secrets.CI_BOT_TOKEN }}@${DOMAIN}/${REPO_PATH}"
|
||||
PUSH_URL="https://${{ vars.WORKER_USERNAME }}:${{ secrets.CI_BOT_TOKEN }}@${DOMAIN}/${REPO_PATH}"
|
||||
else
|
||||
# SSH URL format: git@git.b4l.co.th:B4L/repo-name.git
|
||||
DOMAIN=$(echo $REPO_URL | sed 's|git@\([^:]*\):.*|\1|')
|
||||
REPO_PATH=$(echo $REPO_URL | sed 's|git@[^:]*:\(.*\)|\1|')
|
||||
PUSH_URL="https://ci-bot:${{ secrets.CI_BOT_TOKEN }}@${DOMAIN}/${REPO_PATH}"
|
||||
PUSH_URL="https://${{ vars.WORKER_USERNAME }}:${{ secrets.CI_BOT_TOKEN }}@${DOMAIN}/${REPO_PATH}"
|
||||
fi
|
||||
|
||||
echo "Repository URL: $REPO_URL"
|
||||
echo "Domain: $DOMAIN"
|
||||
echo "Repository Path: $REPO_PATH"
|
||||
echo "Worker: ${{ vars.WORKER_USERNAME }}"
|
||||
|
||||
# Commit with inline git configuration and [skip actions] flag
|
||||
git -c user.name="${{ vars.WORKER_USERNAME }}" -c user.email="${{ vars.WORKER_EMAIL }}" commit -m "Auto-sort: Move DS_ and IMG_ prefixed files to correct directories [skip actions]
|
||||
|
||||
- Moved datasheet files (DS_*) to docs/datasheets/
|
||||
- Moved image files (IMG_*) to docs/images/
|
||||
- Automated by Gitea Actions auto-sort workflow"
|
||||
|
||||
echo "Pushing to: https://${DOMAIN}/${REPO_PATH} (with authentication)"
|
||||
git push $PUSH_URL HEAD:${{ github.ref_name }}
|
||||
|
||||
- name: Create summary
|
||||
- name: Log results
|
||||
run: |
|
||||
echo "## Auto-Sort Results" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
if [ "${{ steps.sort_files.outputs.files_moved }}" = "true" ]; then
|
||||
echo "✅ Files were automatically moved to correct directories" >> $GITHUB_STEP_SUMMARY
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Moved Files:" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- Datasheet files (DS_*) → docs/datasheets/" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- Image files (IMG_*) → docs/images/" >> $GITHUB_STEP_SUMMARY
|
||||
# Check if files were moved by looking at the output from sort_files step
|
||||
FILES_MOVED_OUTPUT="${{ steps.sort_files.outputs.files_moved }}"
|
||||
echo "Auto-Sort Results:"
|
||||
echo "Debug: files_moved output = '$FILES_MOVED_OUTPUT'"
|
||||
|
||||
if [ "$FILES_MOVED_OUTPUT" = "true" ]; then
|
||||
echo "✅ Files were automatically moved to correct directories"
|
||||
echo "- Datasheet files (DS_*) → docs/datasheets/"
|
||||
echo "- Image files (IMG_*) → docs/images/"
|
||||
else
|
||||
echo "ℹ️ No files needed to be moved - all files are properly organized" >> $GITHUB_STEP_SUMMARY
|
||||
echo "ℹ️ No files needed to be moved - all files are properly organized"
|
||||
fi
|
||||
echo "" >> $GITHUB_STEP_SUMMARY
|
||||
echo "### Supported Prefixes:" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **DS_**: Datasheets (PDF, DOC, DOCX, TXT)" >> $GITHUB_STEP_SUMMARY
|
||||
echo "- **IMG_**: Images (PNG, JPG, SVG, GIF, PDF, WEBP)" >> $GITHUB_STEP_SUMMARY
|
||||
|
||||
echo "Supported Prefixes:"
|
||||
echo "- DS_: Datasheets (PDF, DOC, DOCX, TXT)"
|
||||
echo "- IMG_: Images (PNG, JPG, SVG, GIF, PDF, WEBP)"
|
||||
|
||||
BIN
DS_AP7366EA.pdf
BIN
DS_cp2104.pdf
@@ -27,7 +27,19 @@ Ensure your Gitea instance has Actions enabled:
|
||||
- Value: Paste the token from step 2
|
||||
- Click "Add Secret"
|
||||
|
||||
### 4. Enable Repository Actions
|
||||
### 4. Add Repository Variables
|
||||
1. **Go to Repository Settings**:
|
||||
- Navigate to your repository → Settings → Variables
|
||||
2. **Add Worker Email Variable**:
|
||||
- Name: `WORKER_EMAIL`
|
||||
- Value: Email for git commits (e.g., `ci-bot@your-domain.com`)
|
||||
- Click "Add Variable"
|
||||
3. **Add Worker Username Variable**:
|
||||
- Name: `WORKER_USERNAME`
|
||||
- Value: Username for git commits (e.g., `CI Auto-Sort Bot`)
|
||||
- Click "Add Variable"
|
||||
|
||||
### 5. Enable Repository Actions
|
||||
1. **Repository Settings**: Go to Settings → Actions
|
||||
2. **Enable Actions**: Check "Enable Actions"
|
||||
3. **Allow all actions**: Select appropriate action permissions
|
||||
@@ -53,6 +65,12 @@ on:
|
||||
branches: [ main ]
|
||||
```
|
||||
|
||||
### Infinite Loop Prevention
|
||||
The workflow uses the `[skip actions]` flag in commit messages to prevent infinite loops:
|
||||
- When files are moved, the commit message includes `[skip actions]`
|
||||
- This prevents the workflow from triggering again on its own commits
|
||||
- Standard Gitea Actions approach for preventing recursive execution
|
||||
|
||||
### Authentication Method
|
||||
The workflow uses token-based authentication and dynamically detects the repository URL:
|
||||
```yaml
|
||||
@@ -209,6 +227,8 @@ When reporting issues, include:
|
||||
- [ ] Gitea Actions enabled on instance
|
||||
- [ ] CI bot token created with `repo` scope
|
||||
- [ ] `CI_BOT_TOKEN` secret added to repository
|
||||
- [ ] `WORKER_EMAIL` variable added to repository
|
||||
- [ ] `WORKER_USERNAME` variable added to repository
|
||||
- [ ] Repository Actions enabled
|
||||
- [ ] Test files created and pushed
|
||||
- [ ] Workflow executed successfully
|
||||
|
||||
BIN
IMG_0354.png
|
Before Width: | Height: | Size: 250 KiB |
BIN
IMG_0355.png
|
Before Width: | Height: | Size: 247 KiB |
BIN
IMG_0358.png
|
Before Width: | Height: | Size: 283 KiB |
BIN
IMG_0359.png
|
Before Width: | Height: | Size: 281 KiB |
BIN
docs/datasheets/DS_AD8411AWBRZ-RL.pdf
Normal file
|
Before Width: | Height: | Size: 250 KiB |
|
Before Width: | Height: | Size: 247 KiB |
|
Before Width: | Height: | Size: 283 KiB |
|
Before Width: | Height: | Size: 281 KiB |