feat: add automatic wiki sync to CI workflow (v0.2.7)
- Added wiki-sync job to .gitea/workflows/test.yml - Runs only on pushes to master branch - Automatically copies docs/wiki/*.md to Gogs wiki repository - Supports token-based authentication via secrets.GITHUB_TOKEN - Handles wiki initialization if repository doesn't exist - Bumped version to 0.2.7 Wiki sync will now automatically update the Gogs wiki at https://gogs.tftsr.com/sarman/tftsr-devops_investigation/wiki whenever docs/wiki/ files are modified on master.
This commit is contained in:
parent
5f9798a4fd
commit
94b486b801
@ -82,3 +82,94 @@ jobs:
|
|||||||
git checkout FETCH_HEAD
|
git checkout FETCH_HEAD
|
||||||
- run: npm ci --legacy-peer-deps
|
- run: npm ci --legacy-peer-deps
|
||||||
- run: npm run test:run
|
- run: npm run test:run
|
||||||
|
|
||||||
|
wiki-sync:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if: github.ref == 'refs/heads/master'
|
||||||
|
container:
|
||||||
|
image: alpine:latest
|
||||||
|
steps:
|
||||||
|
- name: Install dependencies
|
||||||
|
run: apk add --no-cache git openssh-client
|
||||||
|
|
||||||
|
- name: Checkout main repository
|
||||||
|
run: |
|
||||||
|
git init
|
||||||
|
git remote add origin http://172.0.0.29:3000/sarman/tftsr-devops_investigation.git
|
||||||
|
git fetch --depth=1 origin $GITHUB_SHA
|
||||||
|
git checkout FETCH_HEAD
|
||||||
|
|
||||||
|
- name: Configure git
|
||||||
|
run: |
|
||||||
|
git config --global user.email "actions@gitea.local"
|
||||||
|
git config --global user.name "Gitea Actions"
|
||||||
|
|
||||||
|
- name: Clone wiki repository
|
||||||
|
run: |
|
||||||
|
cd /tmp
|
||||||
|
# Use token authentication if available, fallback to unauthenticated
|
||||||
|
if [ -n "${{ secrets.GITHUB_TOKEN }}" ]; then
|
||||||
|
WIKI_URL="http://${{ secrets.GITHUB_TOKEN }}@172.0.0.29:3000/sarman/tftsr-devops_investigation.wiki.git"
|
||||||
|
else
|
||||||
|
WIKI_URL="http://172.0.0.29:3000/sarman/tftsr-devops_investigation.wiki.git"
|
||||||
|
fi
|
||||||
|
git clone "$WIKI_URL" wiki || true
|
||||||
|
|
||||||
|
- name: Initialize wiki if clone failed
|
||||||
|
run: |
|
||||||
|
if [ ! -d /tmp/wiki ]; then
|
||||||
|
echo "Wiki repository doesn't exist yet or clone failed, initializing..."
|
||||||
|
mkdir -p /tmp/wiki
|
||||||
|
cd /tmp/wiki
|
||||||
|
git init
|
||||||
|
git checkout -b master
|
||||||
|
echo "# Wiki" > Home.md
|
||||||
|
git add Home.md
|
||||||
|
git commit -m "Initial wiki commit"
|
||||||
|
if [ -n "${{ secrets.GITHUB_TOKEN }}" ]; then
|
||||||
|
WIKI_URL="http://${{ secrets.GITHUB_TOKEN }}@172.0.0.29:3000/sarman/tftsr-devops_investigation.wiki.git"
|
||||||
|
else
|
||||||
|
WIKI_URL="http://172.0.0.29:3000/sarman/tftsr-devops_investigation.wiki.git"
|
||||||
|
fi
|
||||||
|
git remote add origin "$WIKI_URL"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Sync wiki files
|
||||||
|
run: |
|
||||||
|
# Copy all markdown files from docs/wiki/ to wiki repo root
|
||||||
|
if [ -d "docs/wiki" ] && [ "$(ls -A docs/wiki/*.md 2>/dev/null)" ]; then
|
||||||
|
cp -v docs/wiki/*.md /tmp/wiki/
|
||||||
|
echo "Copied $(ls docs/wiki/*.md | wc -l) wiki files"
|
||||||
|
else
|
||||||
|
echo "No wiki markdown files found in docs/wiki/"
|
||||||
|
fi
|
||||||
|
|
||||||
|
- name: Commit and push wiki changes
|
||||||
|
run: |
|
||||||
|
cd /tmp/wiki
|
||||||
|
git add -A
|
||||||
|
|
||||||
|
# Check if there are any changes
|
||||||
|
if git diff --staged --quiet; then
|
||||||
|
echo "No wiki changes to commit"
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Commit changes
|
||||||
|
git commit -m "docs: sync from docs/wiki/ at commit ${GITHUB_SHA:0:8}"
|
||||||
|
|
||||||
|
# Prepare push URL with token if available
|
||||||
|
if [ -n "${{ secrets.GITHUB_TOKEN }}" ]; then
|
||||||
|
WIKI_URL="http://${{ secrets.GITHUB_TOKEN }}@172.0.0.29:3000/sarman/tftsr-devops_investigation.wiki.git"
|
||||||
|
else
|
||||||
|
WIKI_URL="http://172.0.0.29:3000/sarman/tftsr-devops_investigation.wiki.git"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Push to wiki
|
||||||
|
if git push "$WIKI_URL" master; then
|
||||||
|
echo "✓ Wiki successfully synced"
|
||||||
|
else
|
||||||
|
echo "⚠ Wiki push failed - you may need to configure authentication"
|
||||||
|
echo " To enable automatic wiki sync, add a Gitea token with repository write access"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"productName": "TFTSR",
|
"productName": "TFTSR",
|
||||||
"version": "0.2.6",
|
"version": "0.2.7",
|
||||||
"identifier": "com.tftsr.devops",
|
"identifier": "com.tftsr.devops",
|
||||||
"build": {
|
"build": {
|
||||||
"frontendDist": "../dist",
|
"frontendDist": "../dist",
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user