name: Skyweave Test, Lint, and Deploy Ritual on: push: branches: [ master ] pull_request: branches: [ master ] jobs: test-and-lint: name: Test and Lint Code runs-on: ubuntu-latest # This container definition is more specific and includes all tools from the start. container: image: alpine:latest # A clean, basic image # Pass the GitHub PAT to the container so it can clone actions options: --env GITEA_PAT=${{ secrets.GH_PAT }} steps: - name: 1. Install System Dependencies run: | echo "Sanctifying container with all necessary tools..." # Install everything needed for the entire job at the beginning apk add --no-cache git curl nodejs-current lua5.1-dev build-base luacheck luarocks - name: 2. Install Lua Dependencies run: | echo "Installing Lua scripture..." luarocks-5.1 install busted # Note: The checkout step will happen after this, so file copying must happen later. - name: 3. Authenticate to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: 4. Checkout Repository Code uses: actions/checkout@v4 with: # Use the PAT for checking out the repository code itself token: ${{ secrets.GH_PAT }} - name: 5. Run Luacheck Scrutiny run: | echo "Scanning Lua scripture..." luacheck --std lua51 . - name: 6. Perform Unit Inquisition (Busted) run: | echo "Initiating unit tests..." # Copy the library needed for testing right before the test runs cp lib/json.lua skyweave/ busted --lua=lua5.1 --verbose spec/ # The deploy job remains the same, but also benefits from authentication deploy-to-device: name: Deploy to Roof Unit needs: test-and-lint runs-on: ubuntu-latest if: github.event_name == 'push' && github.ref == 'refs/heads/master' steps: - name: 1. Authenticate to Docker Hub uses: docker/login-action@v3 with: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} - name: 2. Checkout Repository Code uses: actions/checkout@v4 with: token: ${{ secrets.GH_PAT }} - name: 3. Prepare SSH Environment # ... this part remains exactly the same as the previous version ... run: | echo "Preparing the sacred keys and crypto-litany for SSH communion..." mkdir -p ~/.ssh/ echo "${{ secrets.ROOF_UNIT_SSH_KEY }}" > ~/.ssh/id_rsa chmod 600 ~/.ssh/id_rsa ssh-keyscan -H "${{ secrets.ROOF_UNIT_HOSTNAME }}" >> ~/.ssh/known_hosts echo "Host roof-unit" > ~/.ssh/config echo " HostName ${{ secrets.ROOF_UNIT_HOSTNAME }}" >> ~/.ssh/config echo " User ${{ secrets.ROOF_UNIT_USER }}" >> ~/.ssh/config echo " IdentityFile ~/.ssh/id_rsa" >> ~/.ssh/config echo " KexAlgorithms +diffie-hellman-group1-sha1" >> ~/.ssh/config echo " HostKeyAlgorithms +ssh-rsa" >> ~/.ssh/gitea/runners/gitea-runner-1/config echo " MACs +hmac-sha1" >> ~/.ssh/config echo " PubkeyAcceptedAlgorithms +ssh-rsa" >> ~/.ssh/config - name: 4. Execute Deployment Ritual run: | echo "Initiating deployment sequence..." chmod +x ./skyweave_deploy.sh ./skyweave_deploy.sh