diff --git a/.github/workflows/deploy-to-azure.yml b/.github/workflows/deploy-to-azure.yml new file mode 100644 index 0000000..a8c8a42 --- /dev/null +++ b/.github/workflows/deploy-to-azure.yml @@ -0,0 +1,66 @@ +name: Deploy to Azure Static Web Apps +on: + workflow_dispatch: + inputs: + environment: + description: 'Environment to deploy to' + required: true + default: 'development' + type: choice + options: + - production + - staging + - development + - testing +jobs: + + set-github-environment: + runs-on: ubuntu-latest + outputs: + environment: ${{ steps.set-env.outputs.target_env }} + steps: + - name: Set Environment + id: set-env + run: | + case "${{ inputs.environment }}" in + testing) echo "target_env=Testing" >> $GITHUB_OUTPUT ;; + development) echo "target_env=dev" >> $GITHUB_OUTPUT ;; + staging) echo "target_env=stage" >> $GITHUB_OUTPUT ;; + production) echo "target_env=prod" >> $GITHUB_OUTPUT ;; + esac + + build-and-deploy: + needs: set-github-environment + runs-on: ubuntu-latest + environment: ${{ needs.set-github-environment.outputs.environment }} + steps: + - name: Checkout Code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.inputs.environment }} + - name: Setup Node.js + uses: actions/setup-node@v3 + with: + node-version: '20' + - name: Install Dependencies + run: npm install + - name: Ingest Environment Variables + run: | + touch .env + echo '${{ vars.ENV_CONFIG }}' | jq -r 'to_entries | map("\(.key)=\(.value)") | .[]' > .env + echo CI=false >> .env + - name: Build Project + run: npm run generate + - name: Copy WebApp Config + run: cp staticwebapp.config.json .output/public/staticwebapp.config.json + + - name: Deploy to Azure Static Web Apps + id: deploy + uses: Azure/static-web-apps-deploy@v1 + with: + azure_static_web_apps_api_token: ${{ secrets.AZURE_STATIC_WEB_APPS_API_TOKEN }} + action: "upload" + app_location: ".output/public" # App source code path + api_location: "" # Api source code path - optional + output_location: "" # Built app content directory - optional + skip_app_build: true \ No newline at end of file diff --git a/staticwebapp.config.json b/staticwebapp.config.json new file mode 100644 index 0000000..4a1bb1f --- /dev/null +++ b/staticwebapp.config.json @@ -0,0 +1,5 @@ +{ + "navigationFallback": { + "rewrite": "/index.html" + } +} \ No newline at end of file