Fix CORS issues for contact form and job application submissions #3
This file contains hidden or 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 Backend to Google Apps Script | |
| on: | |
| push: | |
| branches: [main, master] | |
| paths: ['backend/**'] | |
| workflow_dispatch: | |
| inputs: | |
| deploy_description: | |
| description: 'Deployment description' | |
| required: false | |
| default: 'Automated deployment from GitHub Actions' | |
| jobs: | |
| deploy: | |
| runs-on: ubuntu-latest | |
| defaults: | |
| run: | |
| working-directory: ./backend | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '18' | |
| cache: 'npm' | |
| cache-dependency-path: backend/package-lock.json | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Install Google Apps Script CLI | |
| run: npm install -g @google/clasp | |
| - name: Create .clasprc.json | |
| run: | | |
| echo '${{ secrets.CLASPRC_JSON }}' > ~/.clasprc.json | |
| - name: Setup environment variables | |
| run: | | |
| echo "CLASP_SCRIPT_ID=${{ secrets.CLASP_SCRIPT_ID }}" > .env | |
| echo "DEPLOYMENT_DESCRIPTION=${{ github.event.inputs.deploy_description || 'Automated deployment from GitHub Actions' }}" >> .env | |
| echo "DEPLOYMENT_VERSION_DESCRIPTION=Deploy from commit ${{ github.sha }}" >> .env | |
| - name: Validate environment | |
| run: | | |
| if [ -z "${{ secrets.CLASP_SCRIPT_ID }}" ]; then | |
| echo "Error: CLASP_SCRIPT_ID secret is not set" | |
| exit 1 | |
| fi | |
| if [ -z "${{ secrets.CLASPRC_JSON }}" ]; then | |
| echo "Error: CLASPRC_JSON secret is not set" | |
| exit 1 | |
| fi | |
| - name: Deploy to Google Apps Script | |
| run: | | |
| # Update .clasp.json with script ID | |
| cat > .clasp.json << EOF | |
| { | |
| "scriptId": "${{ secrets.CLASP_SCRIPT_ID }}", | |
| "rootDir": "", | |
| "scriptExtensions": [".js", ".gs"], | |
| "htmlExtensions": [".html"], | |
| "jsonExtensions": [".json"], | |
| "filePushOrder": [], | |
| "skipSubdirectories": false | |
| } | |
| EOF | |
| # Push code | |
| clasp push --force | |
| # Deploy | |
| clasp deploy --description "${{ github.event.inputs.deploy_description || 'Automated deployment from GitHub Actions' }}" | |
| - name: Clean up credentials | |
| if: always() | |
| run: | | |
| rm -f ~/.clasprc.json | |
| rm -f .env | |
| rm -f .clasp.json |