Go build is not working properly in github actions

I am trying to build a azure function app using golang. If the handler is build in local and deployed to function it’s working fine.

If it’s build in github action it’s corrupting.

Both builds on linux and same go version 1.20.4 .
I also noticed the build file size is 24 MB in local and 12 MB in github actions.

Why build file from github actions is not woking.What could be the reason?

here is my yml file:

name: Build and deploy Go project to Azure Function App - myfinapp18-dev

on:
  push:
    branches:
      - dev
    paths:
      - backend-api/**
      - .github/workflows/backend_dev.yml
  workflow_dispatch:

env:
  AZURE_FUNCTIONAPP_PACKAGE_PATH: backend-api 
  GO_VERSION: '1.20.4' 
  

jobs:
  build:
    runs-on: ubuntu-latest

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

      - name: Setup Go version
        uses: actions/setup-go@v4
        with:
          go-version: ${{ env.GO_VERSION }}
          cache-dependency-path: backend-api/go.sum

      - name: Build
        run: |
          cd backend-api
          go build -o handler handler.go
          ls -R
          

      - name: Upload artifact for deployment job
        uses: actions/upload-artifact@v3
        with:
            name: go-app
            path: backend-api

  deploy:
    runs-on: ubuntu-latest
    needs: build
    environment:
      name: 'Production'
      url: ${{ steps.deploy-to-function.outputs.webapp-url }}

    steps:
      - name: Download artifact from build job
        uses: actions/download-artifact@v3
        with:
          name: go-app
          path: backend-api

      - name: "Login"
        uses: azure/login@v1
        with:
          creds: ${{ secrets.AZURE_FUNCTION_RBAC_CREDENTIALS_DEV }}

      - name: 'Deploy to Azure Functions'
        uses: Azure/functions-action@v1
        id: deploy-to-function
        with:
          app-name: 'myfinapp18-dev'
          slot-name: 'Production'
          package: ${{ env.AZURE_FUNCTIONAPP_PACKAGE_PATH }}

Hi and welcome! Please share the error log part that breaks the remote build to make things easier :blush:

Hi
I just set CGO_ENABLED=1, by default it’s 0. It’s working now.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.