name: Deploy Static Website on: push: branches: [ main ] workflow_dispatch: jobs: build-and-deploy: runs-on: static-sites steps: - name: Clone Repository run: | echo "Starting repository clone..." # Clean workspace first rm -rf ./* || true # Clone the repository git clone $GITHUB_SERVER_URL/$GITHUB_REPOSITORY . git checkout $GITHUB_SHA echo "Repository contents:" ls -la - name: Install Node.js run: | echo "Installing Node.js using Alpine package manager..." # Update package list and install required tools apk update # Install Node.js and npm from Alpine packages apk add nodejs npm # Verify installation echo "Node.js version:" node --version echo "npm version:" npm --version - name: Build site run: | echo "Building site..." echo "Current directory contents:" ls -la # Install dependencies echo "Installing npm dependencies..." npm install # Build the site echo "Running build command..." npm run build echo "Build output:" ls -la dist/ - name: Deploy to static-websites run: | echo "Deploying to static-websites..." SITE_NAME=${GITHUB_REPOSITORY##*/} DEPLOY_PATH="/static-websites/${SITE_NAME}" echo "Creating deployment directory: ${DEPLOY_PATH}" mkdir -p "${DEPLOY_PATH}" echo "Copying files to deployment directory..." cp -r dist/* "${DEPLOY_PATH}/" echo "Deployed files:" ls -la "${DEPLOY_PATH}"