Merge pull request #5 from StoppedwummPython/StoppedwummPython-patch-1 #52
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 | |
| 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: | |
| # This job runs only after the 'build' job has successfully completed | |
| needs: build | |
| # This job should only run on a push to the main branch, not on pull requests | |
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Download Artifacts | |
| uses: actions/download-artifact@v4 | |
| with: | |
| name: eaglercraft-clients | |
| path: out/ | |
| - name: Install Butler | |
| run: | | |
| # -L follows redirects | |
| # -O specifies output name | |
| curl -L -o butler.zip https://broth.itch.ovh/butler/linux-amd64/LATEST/archive/default | |
| unzip butler.zip | |
| # GNU unzip tends to not set the executable bit even though it's set in the .zip | |
| chmod +x butler | |
| # just a sanity check run (and also helpful in case you're sharing CI logs) | |
| ./butler -V | |
| - name: Deploy Manually using Git and LFS | |
| run: | | |
| # 1. Configure Git LFS | |
| # This command initializes the Git LFS client in the runner environment. | |
| git lfs install | |
| # 2. Clone the destination repository using a Personal Access Token (PAT) | |
| # We clone it into a new directory named 'deploy_repo'. | |
| 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. Clean the working directory | |
| # This command removes all existing files and folders from the repository. | |
| echo "Cleaning out old files..." | |
| git rm -rf . || true | |
| # 5. Copy the new files from the build artifact | |
| echo "Copying new website files..." | |
| cp -r ../out/* . | |
| # 6. Create .nojekyll file to disable Jekyll processing | |
| # This tells GitHub Pages to treat the repository as a pure static site. | |
| echo "Creating .nojekyll file..." | |
| touch .nojekyll | |
| # 7. Configure Git user for the commit | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| # 8. Add, commit, and push the changes | |
| echo "Preparing to commit..." | |
| # Add all new files to the staging area, including the new .nojekyll file. | |
| git add . | |
| # Check if there are any changes to commit. | |
| if git diff --staged --quiet; then | |
| echo "No changes detected. Nothing to commit." | |
| else | |
| echo "Committing changes..." | |
| git commit -m "Automated deployment of static files | Source: ${{ github.sha }}" | |
| echo "Pushing to remote..." | |
| # The push command will upload LFS files and commit the changes. | |
| git push -u origin main | |
| fi | |
| env: | |
| # This makes the PAT available within the script. | |
| PAT: ${{ secrets.PAT }} | |