gigalixir / gigalixir-cli

MIT License
52 stars 45 forks source link

Newly added migration file might not be run in the auto-deployment workflow #81

Closed MarekZhang closed 3 years ago

MarekZhang commented 3 years ago

My team uses Github action to build a auto-deployment pipeline. Part of the commands are as follows:

- name: Auto Deploy
        run: |
          sudo pip3 install gigalixir
          gigalixir login -e "${{ secrets.GIGALIXIR_USERNAME }}" -y -p "${{ secrets.GIGALIXIR_PASSWORD }}"
          gigalixir git:remote ${{ secrets.APP_NAME }}
          git push -f gigalixir HEAD:refs/heads/main
- name: Migration
        run: |
          mkdir ~/.ssh
          printf "Host *\n StrictHostKeyChecking no" > ~/.ssh/config
          echo "${{ secrets.SSH_KEY }}" > ~/.ssh/id_rsa
          chmod 400 ~/.ssh/id_rsa
          gigalixir ps:migrate -a ${{ secrets.APP_NAME }}

It seems that Gigalixir needs some reaction time for pushing new files to the server. So there are chances that the gigalixir ps:migrate -a ${{ secrets.APP_NAME }} command would be run before the newly added migration files being deployed on the server. As shown in the image, this deployment contains a newly added migration file, but the server says migrations already up

Screenshot 2021-06-23 at 11 07 17

Do we have any solution to this? if I operated in the wrong way, please correct me.

Thanks

jesseshieh commented 3 years ago

Have you considered using this instead? https://github.com/marketplace/actions/gigalixir-action

If you do continue to roll it yourself, running migrations requires that you wait until the deployment is successful. This means polling gigalixir ps to see when the new replica is healthy.

MarekZhang commented 3 years ago

Thanks, Jesse, I will compare these two solutions.