Skip to content

[sync] Update embedded LibHud from standalone #14

[sync] Update embedded LibHud from standalone

[sync] Update embedded LibHud from standalone #14

name: Sync to Standalone Repos
on:
push:
branches: [development]
paths:
- 'src/imperazim/command/**'
- 'src/imperazim/form/**'
- 'src/imperazim/packet/**'
- 'src/imperazim/hud/**'
- 'src/imperazim/db/**'
- 'src/imperazim/serializer/**'
jobs:
detect-changes:
if: "!contains(github.event.head_commit.message, '[sync]')"
runs-on: ubuntu-latest
outputs:
command: ${{ steps.filter.outputs.command }}
form: ${{ steps.filter.outputs.form }}
packet: ${{ steps.filter.outputs.packet }}
hud: ${{ steps.filter.outputs.hud }}
db: ${{ steps.filter.outputs.db }}
serializer: ${{ steps.filter.outputs.serializer }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2
- name: Detect changed modules
id: filter
run: |
CHANGED=$(git diff --name-only HEAD~1 HEAD)
echo "command=$(echo "$CHANGED" | grep -q 'src/imperazim/command/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "form=$(echo "$CHANGED" | grep -q 'src/imperazim/form/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "packet=$(echo "$CHANGED" | grep -q 'src/imperazim/packet/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "hud=$(echo "$CHANGED" | grep -q 'src/imperazim/hud/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "db=$(echo "$CHANGED" | grep -q 'src/imperazim/db/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
echo "serializer=$(echo "$CHANGED" | grep -q 'src/imperazim/serializer/' && echo 'true' || echo 'false')" >> $GITHUB_OUTPUT
sync-command:
needs: detect-changes
if: needs.detect-changes.outputs.command == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout EasyLibrary
uses: actions/checkout@v4
with:
path: easylibrary
- name: Checkout LibCommand
uses: actions/checkout@v4
with:
repository: ImperaZim/LibCommand
ref: development
token: ${{ secrets.SYNC_TOKEN }}
path: standalone
- name: Sync files
run: |
SRC="easylibrary/src/imperazim/command"
DEST="standalone/src/imperazim/command"
# Keep entry point, remove everything else
ENTRY_POINT=""
if [ -f "$DEST/LibCommand.php" ]; then
ENTRY_POINT=$(cat "$DEST/LibCommand.php")
fi
rm -rf "$DEST"
mkdir -p "$DEST"
cp -r "$SRC/"* "$DEST/"
# Restore entry point
if [ -n "$ENTRY_POINT" ]; then
echo "$ENTRY_POINT" > "$DEST/LibCommand.php"
fi
- name: Commit and push
run: |
cd standalone
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git diff --quiet && git diff --cached --quiet; then
echo "No changes to sync"
exit 0
fi
git add src/imperazim/command/
git commit -m "[sync] Update LibCommand from EasyLibrary"
git push
sync-form:
needs: detect-changes
if: needs.detect-changes.outputs.form == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout EasyLibrary
uses: actions/checkout@v4
with:
path: easylibrary
- name: Checkout LibForm
uses: actions/checkout@v4
with:
repository: ImperaZim/LibForm
ref: development
token: ${{ secrets.SYNC_TOKEN }}
path: standalone
- name: Sync files
run: |
SRC="easylibrary/src/imperazim/form"
DEST="standalone/src/imperazim/form"
ENTRY_POINT=""
if [ -f "$DEST/LibForm.php" ]; then
ENTRY_POINT=$(cat "$DEST/LibForm.php")
fi
rm -rf "$DEST"
mkdir -p "$DEST"
cp -r "$SRC/"* "$DEST/"
if [ -n "$ENTRY_POINT" ]; then
echo "$ENTRY_POINT" > "$DEST/LibForm.php"
fi
- name: Commit and push
run: |
cd standalone
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git diff --quiet && git diff --cached --quiet; then
echo "No changes to sync"
exit 0
fi
git add src/imperazim/form/
git commit -m "[sync] Update LibForm from EasyLibrary"
git push
sync-packet:
needs: detect-changes
if: needs.detect-changes.outputs.packet == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout EasyLibrary
uses: actions/checkout@v4
with:
path: easylibrary
- name: Checkout LibPacket
uses: actions/checkout@v4
with:
repository: ImperaZim/LibPacket
ref: development
token: ${{ secrets.SYNC_TOKEN }}
path: standalone
- name: Sync files
run: |
SRC="easylibrary/src/imperazim/packet"
DEST="standalone/src/imperazim/packet"
ENTRY_POINT=""
if [ -f "$DEST/LibPacket.php" ]; then
ENTRY_POINT=$(cat "$DEST/LibPacket.php")
fi
rm -rf "$DEST"
mkdir -p "$DEST"
cp -r "$SRC/"* "$DEST/"
if [ -n "$ENTRY_POINT" ]; then
echo "$ENTRY_POINT" > "$DEST/LibPacket.php"
fi
- name: Commit and push
run: |
cd standalone
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git diff --quiet && git diff --cached --quiet; then
echo "No changes to sync"
exit 0
fi
git add src/imperazim/packet/
git commit -m "[sync] Update LibPacket from EasyLibrary"
git push
sync-hud:
needs: detect-changes
if: needs.detect-changes.outputs.hud == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout EasyLibrary
uses: actions/checkout@v4
with:
path: easylibrary
- name: Checkout LibHud
uses: actions/checkout@v4
with:
repository: ImperaZim/LibHud
ref: master
token: ${{ secrets.SYNC_TOKEN }}
path: standalone
- name: Sync files
run: |
SRC="easylibrary/src/imperazim/hud"
DEST="standalone/src/imperazim/hud"
ENTRY_POINT=""
if [ -f "$DEST/LibHud.php" ]; then
ENTRY_POINT=$(cat "$DEST/LibHud.php")
fi
rm -rf "$DEST"
mkdir -p "$DEST"
cp -r "$SRC/"* "$DEST/"
if [ -n "$ENTRY_POINT" ]; then
echo "$ENTRY_POINT" > "$DEST/LibHud.php"
fi
- name: Commit and push
run: |
cd standalone
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git diff --quiet && git diff --cached --quiet; then
echo "No changes to sync"
exit 0
fi
git add src/imperazim/hud/
git commit -m "[sync] Update LibHud from EasyLibrary"
git push
sync-db:
needs: detect-changes
if: needs.detect-changes.outputs.db == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout EasyLibrary
uses: actions/checkout@v4
with:
path: easylibrary
- name: Checkout LibDB
uses: actions/checkout@v4
with:
repository: ImperaZim/LibDB
ref: master
token: ${{ secrets.SYNC_TOKEN }}
path: standalone
- name: Sync files
run: |
SRC="easylibrary/src/imperazim/db"
DEST="standalone/src/imperazim/db"
ENTRY_POINT=""
if [ -f "$DEST/LibDB.php" ]; then
ENTRY_POINT=$(cat "$DEST/LibDB.php")
fi
rm -rf "$DEST"
mkdir -p "$DEST"
cp -r "$SRC/"* "$DEST/"
if [ -n "$ENTRY_POINT" ]; then
echo "$ENTRY_POINT" > "$DEST/LibDB.php"
fi
- name: Commit and push
run: |
cd standalone
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git diff --quiet && git diff --cached --quiet; then
echo "No changes to sync"
exit 0
fi
git add src/imperazim/db/
git commit -m "[sync] Update LibDB from EasyLibrary"
git push
sync-serializer:
needs: detect-changes
if: needs.detect-changes.outputs.serializer == 'true'
runs-on: ubuntu-latest
steps:
- name: Checkout EasyLibrary
uses: actions/checkout@v4
with:
path: easylibrary
- name: Checkout LibSerializer
uses: actions/checkout@v4
with:
repository: ImperaZim/LibSerializer
ref: master
token: ${{ secrets.SYNC_TOKEN }}
path: standalone
- name: Sync files
run: |
SRC="easylibrary/src/imperazim/serializer"
DEST="standalone/src/imperazim/serializer"
ENTRY_POINT=""
if [ -f "$DEST/LibSerializer.php" ]; then
ENTRY_POINT=$(cat "$DEST/LibSerializer.php")
fi
rm -rf "$DEST"
mkdir -p "$DEST"
cp -r "$SRC/"* "$DEST/"
if [ -n "$ENTRY_POINT" ]; then
echo "$ENTRY_POINT" > "$DEST/LibSerializer.php"
fi
- name: Commit and push
run: |
cd standalone
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
if git diff --quiet && git diff --cached --quiet; then
echo "No changes to sync"
exit 0
fi
git add src/imperazim/serializer/
git commit -m "[sync] Update LibSerializer from EasyLibrary"
git push