Home > Software design >  How to make a zip including submodules with Github actions?
How to make a zip including submodules with Github actions?

Time:10-14

I am trying to deploy to AWS using Github actions. The only problem is, that I have a main repo and frontend and backend submodules inside it.

This is the script I am using for deploy:

name: Deploy

on:
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-latest
    steps:
      - name: Checkout source code
        uses: actions/checkout@v2

      - name: Generate deployment package
        run: git submodule update --init --recursive
        run: zip -r deploy.zip . -x '*.git*'

      - name: Get timestamp
        uses: gerred/actions/current-time@master
        id: current-time
        
      - name: Run string replace
        uses: frabert/replace-string-action@master
        id: format-time
        with:
          pattern: '[:\.] '
          string: "${{ steps.current-time.outputs.time }}"
          replace-with: '-'
          flags: 'g'

      - name: Deploy to EB
        uses: einaregilsson/beanstalk-deploy@v18
        with:
          aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}
          aws_secret_key: ${{ secrets.AWS_SECRET_KEY }}
          application_name: test-stage
          environment_name: Testenv-env
          version_label: "${{ steps.format-time.outputs.replaced }}"
          region: eu-center-1
          deployment_package: deploy.zip

The problem is while it is creating a zip. It does not include submodules. Without submodules the project almost contains nothing. Is it possible somehow to iclude them? Or do you have any better solutions for this?

CodePudding user response:

Consulting the actions/checkout documentation, there is a submodules argument (default value false) that controls whether the checkout includes submodules. So, you likely want

steps:
  - name: Checkout source code
    uses: actions/checkout@v2
    with:
      submodules: true
  • Related