name: Development Web build

on:
  push:
    branches: [ master ]

concurrency:
  group: ci-${{github.actor}}-${{github.head_ref || github.run_number}}-${{github.ref}}-devweb
  cancel-in-progress: true

env:
  GODOT_VERSION: 4.3
  EXPORT_NAME: Pixelorama

jobs:
  export-web:
    name: Web Export 🌐
    runs-on: ubuntu-latest
    container:
      image: docker://barichello/godot-ci:4.3
    steps:
      - name: Checkout 🛎️
        uses: actions/checkout@v4
        with:
          submodules: true
      - name: Setup 💻
        run: |
          mkdir -v -p build/web ~/.local/share/godot/export_templates
          mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
      - name: Import resources once 📦
        continue-on-error: true
        run: godot --headless -v --import
      - name: Web Build 🔧
        run: godot --headless -v --export-release "Web" ./build/web/index.html
      - name: Install rsync 📚
        run: |
          apt-get update && apt-get install -y rsync
      - name: Deploy 🚀
        uses: JamesIves/github-pages-deploy-action@v4
        with:
          token: ${{ secrets.GITHUB_TOKEN }}
          single-commit: true
          folder: build/web # The folder the action should deploy.
          target-folder: early_access