nwtgck / actions-netlify

🚀 Netlify deploy from GitHub Actions
MIT License
331 stars 41 forks source link

Support for edge-functions #962

Open das-monki opened 1 year ago

das-monki commented 1 year ago

Hi!

I recently switched over all my functions to edge-functions, and now I'd like to automate their deployment. I haven't seen edge-functions mentioned anywhere here, is this possible at all with this action or are there plans to support them?

By the way, so far this action has worked flawlessly for me, really great tool, thanks for all the work!

joepavitt commented 1 year ago

Just checking to see if you'd had any luck with this? I've pointed to my edge_functions in the netlify.toml (and the pointed the action to this), but no luck getting Netlify to pick them up.

If I use Netlify's built in GH integration, they work great, but we have some GH voodoo to do first (merging content from a couple of repos) before we deploy our website fully, so need to deploy via GH Actions.

das-monki commented 1 year ago

No luck with this action, but haven't tried much. In the end I moved away from using this action and instead use the netlify-cli directly. Worked on first try, and I can use the same command locally.

The step I use to deploy:

    - name: Deploy to Netlify
      env:
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_CHECKOUT }}
      run: "npm install -g netlify-cli && npx netlify deploy --prod --message \"${{ github.event.head_commit.message }}\""
joepavitt commented 1 year ago

Thanks, I ended up going for a different approach of using GitHub actions to handle the repo merging we needed to do, then committing/pushing that to a dedicated live branch and then use Netlify's native GH integration to pull

das-monki commented 1 year ago

Cool you found a way! For reference, this is the complete workflow that I use. This is part of a mono-repo, so I switch the directory in the start to the one I want to deploy. Just including it to promote nix.. 🤓

name: "Build & Deploy App to Netlify"
on:
  pull_request:
  push:
    branches:
      - main
jobs:
  build-and-deploy:
    runs-on: ubuntu-latest
    defaults:
      run:
        working-directory: ./app
    if: "contains(github.event.head_commit.message, '[release app]') || contains(github.event.head_commit.message, '[release all]')"
    steps:
    - name: Checking out the repository
      uses: actions/checkout@v3
      with:
        fetch-depth: 0
    - name: Installing Nix
      uses: cachix/install-nix-action@v18
      with:
        nix_path: nixpkgs=channel:nixos-unstable
    - name: Build the app
      uses: workflow/nix-shell-action@v3.2.0
      with:
        packages: jdk11,nodePackages.npm,nodejs
        script: |
          npm ci
          npm run release -w app
    - name: Deploy to Netlify
      env:
        NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
        NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_CHECKOUT }}
      run: "npm install -g netlify-cli && npx netlify deploy --prod --message \"${{ github.event.head_commit.message }}\""
nwtgck commented 1 year ago

https://github.com/netlify/actions/tree/master/cli uses netlify-cli inside. It is netlify official.

joepavitt commented 1 year ago

It is netlify official.

I had tried it, but just kept hitting limitations of what I needed, and errors, e.g. can't run the build command on a nested directory using that Action.