Update push-dappbundle.yml

This commit is contained in:
tripathyr 2025-07-31 09:59:32 +05:30 committed by GitHub
parent a76ccc890e
commit 1e49d276fd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -1,10 +1,23 @@
name: Workflow push to Dappbundle name: Workflow push to Dappbundle
on: [push] on: [push]
jobs: jobs:
build: build:
name: Build name: Build
runs-on: self-hosted runs-on: self-hosted
steps: steps:
# Optional diagnostics — helps confirm which runner ran and whether Docker perms are OK
- name: Print runner info
run: |
echo "Runner name: $RUNNER_NAME"
echo "Runner OS: $RUNNER_OS"
echo "Runner arch: $RUNNER_ARCH"
echo "Runner user: $(whoami)"
echo "Runner groups: $(id -nG)"
docker --version || echo "Docker not found"
ls -l /var/run/docker.sock || true
docker ps >/dev/null 2>&1 && echo "docker ps OK" || echo "docker ps failed (permission?)"
- name: Executing remote command - name: Executing remote command
uses: appleboy/ssh-action@v1.0.0 uses: appleboy/ssh-action@v1.0.0
with: with:
@ -13,20 +26,43 @@ jobs:
password: ${{ secrets.P_PASSWORD }} password: ${{ secrets.P_PASSWORD }}
port: ${{ secrets.SSH_PORT }} port: ${{ secrets.SSH_PORT }}
script: | script: |
if [ -d "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle" ]; then set -euo pipefail
# 1) Ensure dappbundle exists
if [ -d "${{ secrets.DEPLOYMENT_LOCATION }}/dappbundle" ]; then
echo "Folder exists. Skipping Git clone." echo "Folder exists. Skipping Git clone."
else else
echo "Folder does not exist. Cloning repository..." echo "Folder does not exist. Cloning repository..."
cd ${{ secrets.DEPLOYMENT_LOCATION}}/ && git clone https://github.com/ranchimall/dappbundle.git cd "${{ secrets.DEPLOYMENT_LOCATION }}/" && git clone https://github.com/ranchimall/dappbundle.git
fi fi
if [ -d "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/${{ github.event.repository.name }}" ]; then # Optional: ensure identity is set once, avoids commit failures if not configured
echo "Repository exists. Remove folder " cd "${{ secrets.DEPLOYMENT_LOCATION }}/dappbundle"
rm -r "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/${{ github.event.repository.name }}" git config user.name "ranchimall-bot" || true
git config user.email "bot@ranchimall.net" || true
# 2) Remove old copy of target repo folder
if [ -d "${{ secrets.DEPLOYMENT_LOCATION }}/dappbundle/${{ github.event.repository.name }}" ]; then
echo "Repository exists. Remove folder"
rm -rf "${{ secrets.DEPLOYMENT_LOCATION }}/dappbundle/${{ github.event.repository.name }}"
fi fi
# 3) Clone fresh copy of the source repo into dappbundle
echo "Cloning repository..." echo "Cloning repository..."
cd ${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle && git clone https://github.com/ranchimall/${{ github.event.repository.name }} cd "${{ secrets.DEPLOYMENT_LOCATION }}/dappbundle" && \
git clone --depth=1 "https://github.com/ranchimall/${{ github.event.repository.name }}"
cd "${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/${{ github.event.repository.name }}" && rm -rf .gitattributes .git .github .gitignore # 4) Strip Git metadata from the inner repo (kept exactly as in your script)
cd ${{ secrets.DEPLOYMENT_LOCATION}}/dappbundle/ && git add . && git commit -m "Workflow updating files of ${{ github.event.repository.name }}" && git push "https://ranchimalldev:${{ secrets.RM_ACCESS_TOKEN }}@github.com/ranchimall/dappbundle.git" cd "${{ secrets.DEPLOYMENT_LOCATION }}/dappbundle/${{ github.event.repository.name }}" && \
rm -rf .gitattributes .git .github .gitignore
# 5) Stage everything, commit iff there are changes, then push
cd "${{ secrets.DEPLOYMENT_LOCATION }}/dappbundle"
git add -A .
if git diff --cached --quiet; then
echo "No changes detected. Skipping commit and push."
else
git commit -m "Workflow updating files of ${{ github.event.repository.name }}"
git push "https://ranchimalldev:${{ secrets.RM_ACCESS_TOKEN }}@github.com/ranchimall/dappbundle.git"
fi