Search code examples
githubzipgithub-actions

GitHub Action: zip error: Nothing to do! (try: zip -r ./bundle.zip . -i ./.)


I have a project dir like so:

└── lambda
    └── lambda_handler.py

With the following .yml file

# This is a basic workflow to help you get started with Actions

name: CI

# Controls when the action will run. 
on:
  # Triggers the workflow on push or pull request events but only for the master branch
  push:
    branches: [ master ]
  pull_request:
    branches: [ master ]

  # Allows you to run this workflow manually from the Actions tab
  workflow_dispatch:

# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
  # This workflow contains a single job called "build"
  build:
    # The type of runner that the job will run on
    runs-on: ubuntu-latest
    # Steps represent a sequence of tasks that will be executed as part of the job
    steps:
      - name: zip
        uses: montudor/action-zip@v0.1.0
        with:
          args: "zip -r ./bundle.zip ./."
      - name: default deploy
        uses: appleboy/lambda-action@master
        with:
          aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
          aws_region: eu-west-3
          function_name: generate_crawler_threads_from_processes    
          zip_file: bundle.zip

I keep receiving the following error:

zip error: Nothing to do! (try: zip -qq -r bundle.zip . -i lambda/)

No matter how I tried to perform the zipping step, it didn't work.

Here's a list of other variations of zip command usage I have tried:

zip -r bundle.zip ./*
zip -r ./bundle.zip ./*
zip -r bundle.zip .
zip -r ./bundle.zip .
zip -r bundle.zip /
zip -r bundle.zip ./
zip -r ./bundle.zip .
zip -r bundle.zip *
zip -qq -r bundle.zip .
zip -qq -r bundle.zip . -i .
zip -qq -r bundle.zip . -i lambda/

And many more. Simply it will keep throwing the same error.


Solution

  • According to the montudor/action-zip usage section, it seems you need to add the actions/checkout to access the repository files and directory before using it.

    Something like this:

        steps:
          - uses: actions/checkout@v2
          - name: zip
            uses: montudor/action-zip@v0.1.0
            with:
              args: "zip -r ./bundle.zip ./."
          - uses: actions/upload-artifact@v2
            with:
              name: bundle.zip