Skip to content

feat: add emitter event on location change #176

feat: add emitter event on location change

feat: add emitter event on location change #176

on:
pull_request:
types:
- unlabeled
- closed
env:
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
remove-test:
if: contains(github.event.label.name, 'testing') || contains(github.event.pull_request.labels.*.name, 'testing')
runs-on: ubuntu-latest
permissions:
contents: read
deployments: write
name: Delete Cloudflare Page
steps:
- name: Set Project Name
run: |
export NAME=$(echo ${{ env.BRANCH_NAME }} | tr -d -c '[:alnum:]' | tr '[:upper:]' '[:lower:]')
echo "PROJECT_NAME=widget-${NAME:0:10}" >> $GITHUB_ENV
- name: Delete project if present
uses: actions/github-script@v7
with:
script: |
fetch('https://api.cloudflare.com/client/v4/accounts/${{ secrets.CF_ACCOUNT_ID }}/pages/projects/${{ env.PROJECT_NAME }}', {
method: 'GET',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ${{ secrets.CF_PAGES_API_TOKEN }}'
},
})
.then(r => r.json())
.then(r => {
if (!r || !r.success || !r.result) {
console.log(r)
process.exit(1)
}
fetch('https://api.cloudflare.com/client/v4/accounts/${{ secrets.CF_ACCOUNT_ID }}/pages/projects/${{ env.PROJECT_NAME }}', {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer ${{ secrets.CF_PAGES_API_TOKEN }}'
},
})
.then(r => r.json())
.then(r => {
if (!r?.success) {
console.log(r)
process.exit(1)
}
})
})