Skip to content

feat: add reset-repo ops scripts with dry-run and storage permission … #23

feat: add reset-repo ops scripts with dry-run and storage permission …

feat: add reset-repo ops scripts with dry-run and storage permission … #23

Workflow file for this run

name: Build & Deploy
on:
push:
branches: [master]
workflow_dispatch:
env:
REGISTRY: ghcr.io
IMAGE_NAME: ${{ github.repository }}
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- uses: actions/checkout@v4
- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Extract metadata
id: meta
uses: docker/metadata-action@v5
with:
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
tags: |
type=raw,value=latest,enable={{is_default_branch}}
type=sha,prefix=sha-,suffix=,format=short
- name: Build and push
uses: docker/build-push-action@v5
with:
context: .
file: ./deploy/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy:
needs: build
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/master'
steps:
- name: Deploy to Hetzner via SSH
uses: appleboy/ssh-action@v1.0.3
env:
DEPLOY_SHA: ${{ github.sha }}
with:
host: ${{ secrets.HETZNER_HOST }}
username: ${{ secrets.HETZNER_USER }}
key: ${{ secrets.HETZNER_SSH_KEY }}
script_stop: true
script: |
# Update source code first (in case we need local build fallback)
if [ -d /opt/codewalk-src/.git ]; then
cd /opt/codewalk-src && git pull origin master
else
git clone https://github.com/gupta29470/codewalk.git /opt/codewalk-src
fi
# Ensure deploy script is latest
cp /opt/codewalk-src/deploy/deploy-server.sh /opt/codewalk/deploy-server.sh
chmod +x /opt/codewalk/deploy-server.sh
# Run deploy with SHA from GitHub Actions (first 7 chars)
SHORT_SHA="${DEPLOY_SHA:0:7}"
echo "Deploying SHA: $SHORT_SHA"
DEPLOY_SHA="$SHORT_SHA" /opt/codewalk/deploy-server.sh
- name: Deployment summary
if: always()
run: |
echo "Deploy SHA: ${{ github.sha }}"
echo "Status: ${{ job.status }}"