๐Ÿงต#Deploy on GithubActions

marwi123
marcel ๐ŸŒต โ†—

Hey sure

name: Build and Deploy to Needle Cloud

on:
  push:
    branches: [ main ]

jobs:
  build-and-deploy:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout repository
        uses: actions/checkout@v4

      - name: Setup Node.js
        uses: actions/setup-node@v4
        with:
          node-version: '20.x'
          cache: 'npm'
          cache-dependency-path: path/to/your/nuxt/project

      - name: Install dependencies
        run: npm ci
        working-directory: path/to/your/nuxt/project

      # Build the web project
      - name: Build Vite project
        run: npm run build
        working-directory: path/to/your/nuxt/project
        env:
          NEEDLE_CLOUD_TOKEN: ${{ secrets.NEEDLE_CLOUD_TOKEN }} # cloud token to compress assets in the cloud (assuming they're in the web project's asset folder not using AutoCompress)

      # Deploy to Needle Cloud
      - name: Deploy to Needle Cloud
        uses: needle-tools/deploy-to-needle-cloud-action@v1
        id: deploy
        with:
            token: ${{ secrets.NEEDLE_CLOUD_TOKEN }}
            dir: path/to/your/nuxt/project/.output/public
            name: <your_project_name> # name on needle cloud
            webhookUrl: ${{ secrets.WEBHOOK_URL }} # optional to get a notification on deploy
        env:
          NODE_ENV: production
          NEEDLE_CLOUD_TOKEN: ${{ secrets.NEEDLE_CLOUD_TOKEN }}

      # Display the deployment URL
      - name: Display deployment URL
        run: |
          echo "::notice title=Deployment URL::Deployed to ${{ steps.deploy.outputs.url }}"

See https://github.com/needle-tools/deploy-to-needle-cloud-action

whtw4thewin

Ohhhh so you guys are uploading directly to needle cloud. thanks!

I was trying to use Docker to build an image, it works but obviously the license server and toktx fails, in such case would it be viable to use the ยด.outputยด folder directly? (meaning using directly the local build?) .

marwi123
marcel ๐ŸŒต โ†—

I mean you can install toktx in the container too if you want to ๐Ÿ˜‰ It's what we do in the cloud workers that run the optimization jobs - but if you just pass your token to the build process and run a production build you'll get your assets optimized via needle cloud at deploy/build time and your little github actions worker waits for that - much faster since it's running on a stronger machine then (and doesnt do anything if the asset didnt change so then it's super fast)

whtw4thewin

Yes, but what about the licence server? (I have no idea how it works). If I include directly the .output folder it should be a straightforward build, so Iยดm testing that jeje.

marwi123
marcel ๐ŸŒต โ†—

What about it? The license check is also done with the NEEDLE_CLOUD access token you provide in that case ๐Ÿ™‚

marwi123
marcel ๐ŸŒต โ†—

(1) One is building your nuxt application to .output (2) The other is deploying to Needle Cloud