A ton of refactoring. Promoting stage to production works. Many impro… #60
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy to Server | |
on: | |
push: | |
branches: | |
- main | |
workflow_dispatch: # Allows manual triggering from Github portal. | |
jobs: | |
deploy: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check required secrets | |
run: | | |
if [ -z "${{ secrets.BUNNY_API_KEY }}" ] || [ -z "${{ secrets.APP_NAME }}" ] || [ -z "${{ secrets.STORAGE_ZONE_NAME }}" ]; then | |
echo "Error: One or more required secrets are missing. If you don't have plans to deploy, you can ignore this message or delete /.github/workflows/deploy.yml in your repo." | |
exit 1 | |
fi | |
- name: Checkout code | |
uses: actions/checkout@v4 | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
- name: Install dependencies | |
run: npm ci | |
- name: Build static content | |
run: npm run build | |
env: | |
VITE_BASE_URL: ${{ vars.BASE_URL }} | |
# Important to set the secret-based env vars just in this deploy step to avoid secret exposure to 3rd-party code. | |
- name: Deploy using BunnyCDN | |
run: node ./scripts/deploy.js | |
env: | |
BUNNY_API_KEY: ${{ secrets.BUNNY_API_KEY }} | |
APP_NAME: ${{ secrets.APP_NAME }} | |
STORAGE_ZONE_NAME: ${{ secrets.STORAGE_ZONE_NAME }} | |
COMMIT_HASH: ${{ github.sha }} |