Add configurable worker credentials for git operations

- Replace hardcoded git user email and name with configurable variables
- Add WORKER_EMAIL and WORKER_USERNAME variables for git commits and authentication
- Update workflow to use vars.WORKER_EMAIL and vars.WORKER_USERNAME
- Use WORKER_USERNAME in push URL authentication instead of hardcoded 'ci-bot'
- Update GITEA-ACTIONS-SETUP.md with instructions for setting up repository variables
- Add variables to setup checklist for complete configuration
- Provide flexibility for different organizations and naming conventions
This commit is contained in:
2025-08-11 11:31:59 +07:00
parent 0e800242d7
commit 29b4ffe576
2 changed files with 20 additions and 5 deletions

View File

@@ -83,8 +83,8 @@ jobs:
- 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 config --local user.email "${{ vars.WORKER_EMAIL }}"
git config --local user.name "${{ vars.WORKER_USERNAME }}"
git add docs/datasheets/ docs/images/
git commit -m "Auto-sort: Move DS_ and IMG_ prefixed files to correct directories
@@ -103,17 +103,18 @@ 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 }}"
echo "Pushing to: https://${DOMAIN}/${REPO_PATH} (with authentication)"
git push $PUSH_URL HEAD:${{ github.ref_name }}