76 lines
2.9 KiB
YAML
76 lines
2.9 KiB
YAML
name: Fortress Self-Archival
|
|
on:
|
|
push:
|
|
branches:
|
|
- master
|
|
|
|
jobs:
|
|
archive:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Check out Fortress
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Install Kubectl
|
|
run: |
|
|
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
|
|
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
|
|
|
|
- name: Pin to IPFS Sanctum
|
|
run: |
|
|
# Copy to IPFS pod
|
|
POD_NAME=$(kubectl get pods -l app=ipfs-node -o jsonpath="{.items[0].metadata.name}")
|
|
kubectl exec $POD_NAME -- mkdir -p /tmp/archives/knowledge-fortress
|
|
kubectl cp . $POD_NAME:/tmp/archives/knowledge-fortress
|
|
|
|
# Generate Hash
|
|
CID=$(kubectl exec $POD_NAME -- ipfs add -r -Q /tmp/archives/knowledge-fortress)
|
|
echo "========================================="
|
|
echo "Knowledge Engineering Fortress Archived!"
|
|
echo "CID: $CID"
|
|
echo "========================================="
|
|
|
|
# Clean up
|
|
kubectl exec $POD_NAME -- rm -rf /tmp/archives/knowledge-fortress
|
|
|
|
- name: Mirror to GitHub
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
run: |
|
|
if [ -n "$GITHUB_TOKEN" ]; then
|
|
git remote add github https://x-access-token:${GITHUB_TOKEN}@github.com/mrhavens/${{ github.event.repository.name }}.git
|
|
git push --force --all github
|
|
git push --force --tags github
|
|
echo "Successfully mirrored to GitHub!"
|
|
else
|
|
echo "GITHUB_TOKEN secret not found. Skipping GitHub mirror."
|
|
fi
|
|
|
|
- name: Sync to Radicle Network
|
|
run: |
|
|
RAD_POD=$(kubectl get pods -n radicle -l app=radicle -o jsonpath="{.items[0].metadata.name}")
|
|
kubectl exec -n radicle $RAD_POD -- mkdir -p /tmp/sync-repo
|
|
# We use tar to ensure .git and all hidden files are cleanly preserved
|
|
tar czf - . | kubectl exec -n radicle -i $RAD_POD -- tar xzf - -C /tmp/sync-repo
|
|
|
|
kubectl exec -n radicle $RAD_POD -- bash -c '
|
|
export RAD_HOME=/radicle/.radicle
|
|
export RAD_PASSPHRASE="sovereign"
|
|
export PATH=$PATH:/radicle/bin
|
|
cd /tmp/sync-repo
|
|
chown -R $(id -u):$(id -g) .
|
|
|
|
# Check if repository is already initialized in Radicle
|
|
if ! rad inspect > /dev/null 2>&1; then
|
|
echo "Initializing Radicle repository..."
|
|
rad init --name "${{ github.event.repository.name }}" --description "Sovereign Canon" --default-branch master --public --no-confirm
|
|
else
|
|
echo "Pushing updates to Radicle..."
|
|
git push rad master
|
|
fi
|
|
|
|
# Clean up
|
|
cd /
|
|
rm -rf /tmp/sync-repo
|
|
'
|