deploy: switch to repository owner

pull/39/head
Sven Sauleau 2023-01-09 08:47:23 +00:00
rodzic 672f081da1
commit 669d363d40
1 zmienionych plików z 10 dodań i 10 usunięć

Wyświetl plik

@ -25,13 +25,13 @@ jobs:
CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }} CF_ZONE_ID: ${{ secrets.CF_ZONE_ID }}
CF_DEPLOY_DOMAIN: ${{ secrets.CF_DEPLOY_DOMAIN }} CF_DEPLOY_DOMAIN: ${{ secrets.CF_DEPLOY_DOMAIN }}
# this is needed to get the lowercase version of the actor name # this is needed to get the lowercase version of the repository_owner name
# TODO: switch to some lowercase function in the future when Actions supports it # TODO: switch to some lowercase function in the future when Actions supports it
- name: Set lowercase actor name - name: Set lowercase repository_owner name
run: | run: |
echo $GH_ACTOR | awk '{ print "ACTOR_LOWER=" tolower($0) }' >> ${GITHUB_ENV} echo $GH_OWNER | awk '{ print "OWNER_LOWER=" tolower($0) }' >> ${GITHUB_ENV}
env: env:
GH_ACTOR: ${{ github.actor }} GH_OWNER: ${{ github.repository_owner }}
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: hashicorp/setup-terraform@v2 - uses: hashicorp/setup-terraform@v2
@ -48,7 +48,7 @@ jobs:
- name: Create D1 database - name: Create D1 database
uses: cloudflare/wrangler-action@2.0.0 uses: cloudflare/wrangler-action@2.0.0
with: with:
command: d1 create wildebeest-${{ env.ACTOR_LOWER }} command: d1 create wildebeest-${{ env.OWNER_LOWER }}
apiToken: ${{ secrets.CF_API_TOKEN }} apiToken: ${{ secrets.CF_API_TOKEN }}
continue-on-error: true continue-on-error: true
env: env:
@ -57,7 +57,7 @@ jobs:
- name: retrieve D1 database - name: retrieve D1 database
uses: cloudflare/wrangler-action@2.0.0 uses: cloudflare/wrangler-action@2.0.0
with: with:
command: d1 list | grep wildebeest-${{ env.ACTOR_LOWER }} | awk '{print "d1_id="$2}' >> $GITHUB_ENV command: d1 list | grep wildebeest-${{ env.OWNER_LOWER }} | awk '{print "d1_id="$2}' >> $GITHUB_ENV
apiToken: ${{ secrets.CF_API_TOKEN }} apiToken: ${{ secrets.CF_API_TOKEN }}
env: env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
@ -65,11 +65,11 @@ jobs:
- name: migrate D1 database - name: migrate D1 database
uses: cloudflare/wrangler-action@2.0.0 uses: cloudflare/wrangler-action@2.0.0
with: with:
command: d1 migrations apply wildebeest-${{ env.ACTOR_LOWER }} command: d1 migrations apply wildebeest-${{ env.OWNER_LOWER }}
apiToken: ${{ secrets.CF_API_TOKEN }} apiToken: ${{ secrets.CF_API_TOKEN }}
preCommands: | preCommands: |
echo "*** pre commands ***" echo "*** pre commands ***"
echo -e "[[d1_databases]]\nbinding=\"DATABASE\"\ndatabase_name=\"wildebeest-${{ env.ACTOR_LOWER }}\"\ndatabase_id=\"${{ env.d1_id }}\"" >> wrangler.toml echo -e "[[d1_databases]]\nbinding=\"DATABASE\"\ndatabase_name=\"wildebeest-${{ env.OWNER_LOWER }}\"\ndatabase_id=\"${{ env.d1_id }}\"" >> wrangler.toml
echo "******" echo "******"
env: env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}
@ -93,7 +93,7 @@ jobs:
TF_VAR_cloudflare_api_token: ${{ secrets.CF_API_TOKEN }} TF_VAR_cloudflare_api_token: ${{ secrets.CF_API_TOKEN }}
TF_VAR_cloudflare_zone_id: ${{ secrets.CF_ZONE_ID }} TF_VAR_cloudflare_zone_id: ${{ secrets.CF_ZONE_ID }}
TF_VAR_cloudflare_deploy_domain: ${{ secrets.CF_DEPLOY_DOMAIN }} TF_VAR_cloudflare_deploy_domain: ${{ secrets.CF_DEPLOY_DOMAIN }}
TF_VAR_gh_username: ${{ env.ACTOR_LOWER }} TF_VAR_gh_username: ${{ env.OWNER_LOWER }}
TF_VAR_d1_id: ${{ env.d1_id }} TF_VAR_d1_id: ${{ env.d1_id }}
TF_VAR_access_auth_domain: ${{ env.auth_domain }} TF_VAR_access_auth_domain: ${{ env.auth_domain }}
@ -107,6 +107,6 @@ jobs:
yarn build yarn build
cp -rv ./frontend/dist/* . cp -rv ./frontend/dist/* .
echo "******" echo "******"
command: pages publish --project-name=wildebeest-${{ env.ACTOR_LOWER }} . command: pages publish --project-name=wildebeest-${{ env.OWNER_LOWER }} .
env: env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }} CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CF_ACCOUNT_ID }}