kopia lustrzana https://github.com/cloudflare/wildebeest
68 wiersze
2.0 KiB
YAML
68 wiersze
2.0 KiB
YAML
name: Deploy
|
|
on:
|
|
push:
|
|
pull_request:
|
|
repository_dispatch:
|
|
jobs:
|
|
deploy:
|
|
runs-on: ubuntu-latest
|
|
timeout-minutes: 60
|
|
steps:
|
|
- uses: actions/checkout@v2
|
|
- uses: hashicorp/setup-terraform@v2
|
|
|
|
- name: Setup node.js
|
|
uses: actions/setup-node@v3
|
|
with:
|
|
node-version: 18
|
|
|
|
- name: Create D1 database
|
|
uses: cloudflare/wrangler-action@2.0.0
|
|
with:
|
|
command: d1 create wildebeest-${{ github.actor }}
|
|
apiToken: ${{ secrets.CF_API_TOKEN }}
|
|
continue-on-error: true
|
|
env:
|
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
|
|
|
- name: retrieve D1 database
|
|
uses: cloudflare/wrangler-action@2.0.0
|
|
with:
|
|
command: d1 list | grep wildebeest-${{ github.actor }} | awk '{print "d1_id="$2}' >> $GITHUB_ENV
|
|
apiToken: ${{ secrets.CF_API_TOKEN }}
|
|
env:
|
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
|
|
|
- name: migrate D1 database
|
|
uses: cloudflare/wrangler-action@2.0.0
|
|
with:
|
|
command: d1 migrations apply wildebeest-${{ github.actor }}
|
|
apiToken: ${{ secrets.CF_API_TOKEN }}
|
|
env:
|
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|
|
|
|
- name: Init
|
|
run: terraform init
|
|
working-directory: ./tf
|
|
|
|
- name: Configure
|
|
run: terraform plan && terraform apply -auto-approve
|
|
working-directory: ./tf
|
|
env:
|
|
TF_VAR_cloudflare_account_id: ${{ secrets.CF_ACCOUNT_ID }}
|
|
TF_VAR_cloudflare_api_token: ${{ secrets.CF_API_TOKEN }}
|
|
TF_VAR_gh_username: ${{ github.actor }}
|
|
TF_VAR_d1_id: ${{ env.d1_id }}
|
|
|
|
- name: Publish
|
|
uses: cloudflare/wrangler-action@2.0.0
|
|
with:
|
|
apiToken: ${{ secrets.CF_API_TOKEN }}
|
|
preCommands: |
|
|
echo "*** pre commands ***"
|
|
yarn
|
|
echo "******"
|
|
command: pages publish --project-name=wildebeest-${{ github.actor }} .
|
|
env:
|
|
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
|