Merge pull request #10 from StoppedwummPython/StoppedwummPython-patch-2 #60
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build and Deploy to Static Repo | |
| on: | |
| push: | |
| branches: | |
| - main | |
| - stoppeds-fun-stuff # Added the new branch here | |
| jobs: | |
| # This job builds the client files and uploads them as an artifact | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v3 | |
| - name: Set up JDK 17 | |
| uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'temurin' | |
| java-version: '17' | |
| - name: Install ffmpeg | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y ffmpeg | |
| - name: Copy build config | |
| run: | | |
| cp workflowConfig.json buildtools_config.json | |
| - name: Run Build Script | |
| run: | | |
| chmod +x ./build.sh | |
| ./build.sh | |
| - name: Upload Artifacts | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: eaglercraft-clients | |
| path: out/ | |
| # This job downloads the artifacts and deploys them to the external repository | |
| deploy: | |
| needs: build | |
| # Updated logic to run on either branch | |
| if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/stoppeds-fun-stuff') | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: eaglercraft-clients | |
| path: out/ | |
| - name: Install Butler | |
| run: | | |
| curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default | |
| unzip butler.zip | |
| chmod +x butler | |
| ./butler -V | |
| env: | |
| PAT: ${{ secrets.PAT }} | |
| - name: Deploy Manually using Git and LFS | |
| run: | | |
| # 1. Configure Git LFS | |
| git lfs install | |
| # 2. Clone the destination repository | |
| echo "Cloning destination repository..." | |
| git clone "https://x-access-token:${{ secrets.PAT }}@github.com/StoppedwummPython/eageag.git" deploy_repo | |
| # 3. Navigate into the cloned repository | |
| cd deploy_repo | |
| # 4. Configure Git user | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # 5. Logic to determine where to deploy based on the branch name | |
| CURRENT_BRANCH="${{ github.ref_name }}" | |
| if [ "$CURRENT_BRANCH" == "main" ]; then | |
| echo "--- DEPLOYING MAIN TO ROOT ---" | |
| # Clean root directory except .git folder | |
| # Using find/rm is safer than git rm for bulk wiping while keeping .git | |
| find . -maxdepth 1 ! -name '.git' ! -name '.' -exec rm -rf {} + | |
| # Copy new files to root | |
| cp -r ../out/* . | |
| # Create .nojekyll | |
| touch .nojekyll | |
| elif [ "$CURRENT_BRANCH" == "stoppeds-fun-stuff" ]; then | |
| echo "--- DEPLOYING TO SNAPSHIT DIRECTORY ---" | |
| # Create directory if it doesn't exist | |
| mkdir -p snapshit | |
| # Clean only the snapshit directory | |
| rm -rf snapshit/* | |
| # Copy new files into the subdirectory | |
| cp -r ../out/* snapshit/ | |
| else | |
| echo "Unknown branch $CURRENT_BRANCH. Skipping deployment." | |
| exit 1 | |
| fi | |
| # 6. Add, commit, and push | |
| echo "Preparing to commit..." | |
| # 'git add .' handles both new files and deletions automatically | |
| git add . | |
| if git diff --staged --quiet; then | |
| echo "No changes detected. Nothing to commit." | |
| else | |
| echo "Committing changes..." | |
| git commit -m "Deploy from branch $CURRENT_BRANCH | Source: ${{ github.sha }}" | |
| echo "Pushing to remote..." | |
| git push origin main | |
| fi | |
| env: | |
| PAT: ${{ secrets.PAT }} |