name: Deploy quiXzoom Asia on: push: branches: [main] paths: - 'src/**' - 'scripts/**' - 'package.json' workflow_dispatch: inputs: environment: description: 'Deployment environment' required: true default: 'staging' type: choice options: - staging - production jobs: build: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - name: Setup Node uses: actions/setup-node@v4 with: node-version: '20' - name: Install dependencies run: npm ci || npm install - name: Validate translations run: node scripts/validate.js - name: Build run: node scripts/build.js env: VERSION: ${{ github.ref_name }}-${{ github.sha }} GIT_COMMIT: ${{ github.sha }} GIT_BRANCH: ${{ github.ref_name }} - name: Upload artifact uses: actions/upload-artifact@v4 with: name: dist path: dist/ deploy-staging: needs: build if: github.ref == 'refs/heads/main' && github.event_name == 'push' runs-on: ubuntu-latest environment: staging steps: - uses: actions/checkout@v4 - name: Download artifact uses: actions/download-artifact@v4 with: name: dist path: dist/ - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ap-southeast-1 - name: Deploy to staging run: node scripts/deploy.js --env=staging env: CF_DIST_STAGING: ${{ secrets.CF_DIST_STAGING }} deploy-production: needs: [build, deploy-staging] if: github.ref == 'refs/heads/main' && github.event.inputs.environment == 'production' runs-on: ubuntu-latest environment: production steps: - uses: actions/checkout@v4 - name: Download artifact uses: actions/download-artifact@v4 with: name: dist path: dist/ - name: Configure AWS credentials uses: aws-actions/configure-aws-credentials@v4 with: aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} aws-region: ap-southeast-1 - name: Deploy to production run: node scripts/deploy.js --env=production env: CF_DIST_PRODUCTION: ${{ secrets.CF_DIST_PRODUCTION }}