Skip to content

Commit

Permalink
chore: truncate url to 63 characters
Browse files Browse the repository at this point in the history
  • Loading branch information
gentlementlegen committed Aug 28, 2024
1 parent 9e8491e commit e79bd4a
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 40 deletions.
39 changes: 19 additions & 20 deletions .github/workflows/worker-delete.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
name: Deploy Worker
name: Delete Deployment

on:
push:
workflow_dispatch:
delete:

jobs:
deploy:
delete:
runs-on: ubuntu-latest
name: Deploy
name: Delete Deployment
steps:
- name: Setup Node
uses: actions/setup-node@v4
Expand All @@ -19,27 +18,27 @@ jobs:

- uses: actions/checkout@v4

- name: Update wrangler.toml Name Field
- name: Get Deleted Branch Name
id: get_branch
run: |
branch_name=$(echo '${{ github.event.ref }}' | sed 's#refs/heads/##' | sed 's#[^a-zA-Z0-9]#-#g')
sed -i "s/^name = \"\(.*\)\"$/name = \"\1-${branch_name}\"/" wrangler.toml
echo $branch_name
- name: Deploy with Wrangler
id: wrangler_deploy
echo "branch_name=$branch_name" >> $GITHUB_ENV
- name: Retrieve and Construct Full Worker Name
id: construct_worker_name
run: |
base_name=$(grep '^name = ' wrangler.toml | sed 's/^name = "\(.*\)"$/\1/')
full_worker_name="${base_name}-${{ env.branch_name }}"
# Make sure that it doesnt exceed 63 characters or it will break RFC 1035
full_worker_name=$(echo "${full_worker_name}" | cut -c 1-63)
echo "full_worker_name=$full_worker_name" >> $GITHUB_ENV
- name: Delete Deployment with Wrangler
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.57.0"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
secrets: |
SUPABASE_URL
SUPABASE_KEY
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}
command: delete --name ${{ env.full_worker_name }}

- name: Write Deployment URL to Summary
- name: Output Deletion Result
run: |
echo "### Deployment URL" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.wrangler_deploy.outputs.deployment-url }}" >> $GITHUB_STEP_SUMMARY
echo 'Deployment `${{ env.full_worker_name }}` has been deleted.' >> $GITHUB_STEP_SUMMARY
42 changes: 22 additions & 20 deletions .github/workflows/worker-deploy.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
name: Delete Deployment
name: Deploy Worker

on:
delete:
push:
workflow_dispatch:

jobs:
delete:
deploy:
runs-on: ubuntu-latest
name: Delete Deployment
name: Deploy
steps:
- name: Setup Node
uses: actions/setup-node@v4
Expand All @@ -18,27 +19,28 @@ jobs:

- uses: actions/checkout@v4

- name: Get Deleted Branch Name
id: get_branch
- name: Update wrangler.toml Name Field
run: |
branch_name=$(echo '${{ github.event.ref }}' | sed 's#refs/heads/##' | sed 's#[^a-zA-Z0-9]#-#g')
echo "branch_name=$branch_name" >> $GITHUB_ENV
- name: Retrieve and Construct Full Worker Name
id: construct_worker_name
run: |
base_name=$(grep '^name = ' wrangler.toml | sed 's/^name = "\(.*\)"$/\1/')
full_worker_name="${base_name}-${{ env.branch_name }}"
echo "full_worker_name=$full_worker_name" >> $GITHUB_ENV
- name: Delete Deployment with Wrangler
# Make sure that it doesnt exceed 63 characters or it will break RFC 1035
branch_name=$(echo "${branch_name}" | cut -c 1-63)
sed -i "s/^name = \"\(.*\)\"$/name = \"\1-${branch_name}\"/" wrangler.toml
echo $branch_name
- name: Deploy with Wrangler
id: wrangler_deploy
uses: cloudflare/wrangler-action@v3
with:
wranglerVersion: "3.57.0"
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: delete --name ${{ env.full_worker_name }}

- name: Output Deletion Result
secrets: |
SUPABASE_URL
SUPABASE_KEY
env:
SUPABASE_URL: ${{ secrets.SUPABASE_URL }}
SUPABASE_KEY: ${{ secrets.SUPABASE_KEY }}

- name: Write Deployment URL to Summary
run: |
echo "### Deployment URL" >> $GITHUB_STEP_SUMMARY
echo 'Deployment `${{ env.full_worker_name }}` has been deleted.' >> $GITHUB_STEP_SUMMARY
echo "${{ steps.wrangler_deploy.outputs.deployment-url }}" >> $GITHUB_STEP_SUMMARY

0 comments on commit e79bd4a

Please sign in to comment.