diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..cfdd8ab --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,67 @@ +name: Deploy Workers + +on: + push: + branches: [main] + paths: + - 'cypher-executor/**' + - 'registry/**' + - 'credentials/**' + +jobs: + deploy-cypher-executor: + name: Deploy cypher-executor + runs-on: ubuntu-latest + if: contains(toJson(github.event.commits), 'cypher-executor') || github.event_name == 'workflow_dispatch' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Deploy + working-directory: cypher-executor + run: npx wrangler deploy + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + + deploy-registry: + name: Deploy registry + runs-on: ubuntu-latest + if: contains(toJson(github.event.commits), 'registry') || github.event_name == 'workflow_dispatch' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Deploy + working-directory: registry + run: npx wrangler deploy + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + + deploy-credentials: + name: Deploy credentials + runs-on: ubuntu-latest + if: contains(toJson(github.event.commits), 'credentials') || github.event_name == 'workflow_dispatch' + steps: + - uses: actions/checkout@v4 + - uses: actions/setup-node@v4 + with: + node-version: '20' + - name: Deploy + working-directory: credentials + run: npx wrangler deploy + env: + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + + # 手動觸發:部署全部三個 Worker + deploy-all: + name: Deploy all (manual) + runs-on: ubuntu-latest + if: github.event_name == 'workflow_dispatch' + needs: [deploy-cypher-executor, deploy-registry, deploy-credentials] + steps: + - run: echo "All workers deployed"