Solved it by providing the .env file.
When deploying your code via GitHub actions, there is no .env file in your repo to be used when you build your assets. When you deploy via local command, then it use your .env.
Let me explain:
When you deploy via local command:
vapor deploy production
You will notice it creates a .vapor directory in your project. This will be an exact copy of your project, which is use to build and pushed your project to vapor. The .vapor folder also contains a copy of your .env file of your project.
So when it build your assets, example for VITE:
npm run build
The .env is found and used to build your assets.
This resolves the import.meta.env.VITE_PUSHER_APP_KEY and import.meta.env.VITE_PUSHER_APP_CLUSTER which where not populated.
When you deploy with GuthHub actions, you need provide the .env.
Here is an extract how to pull your env from vapor in your GitHub action deployment script:
- name: Pull ENV
run: vapor env:pull staging
env:
VAPOR_API_TOKEN: ${{ secrets.VAPOR_API_TOKEN }}
- name: Move ENV
run: mv .env.staging .env
The above snippet code should be before your vapor deployment code:
vapor deploy production --commit="${CI_COMMIT_ID}" --message="${CI_MESSAGE}"