diff --git a/.github/workflows/example2.yml b/.github/workflows/example2.yml
index 5f53f18..e2c1890 100644
--- a/.github/workflows/example2.yml
+++ b/.github/workflows/example2.yml
@@ -43,19 +43,40 @@ jobs:
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
command: pages deploy example --project-name=github-actions-example --branch=${{ github.head_ref || github.ref_name }}
id: publish
+ - uses: schnerring/cloudflare-pages-branch-alias-action@v1
+ id: pages-branch-alias
+ with:
+ # git-branch input
+ git-branch: ${{ github.ref_name }}
+ - name: generate alias url
+ id: generate-alias-url
+ if: steps.pages-branch-alias.outputs.alias != 'develop'
+ env:
+ ALIAS: ${{ steps.pages-branch-alias.outputs.alias }}
+ PUBLISH_CFPAGES_URL: ${{ steps.publish.outputs.deployment-url }}
+ run: |
+ [[ $PUBLISH_CFPAGES_URL =~ (https?://)?([a-zA-Z0-9-]+)\.pages\.dev ]]
+ new_url="${ALIAS}${BASH_REMATCH[2]}"
+ echo $new_url
+ echo alias_url=https://${new_url} >> $GITHUB_ENV
- name: Create Job Summary
uses: actions/github-script@v7
env:
CHANGE_BRANCH: ${{ steps.set-production-branch.outputs.summary }}
PUBLISH_CFPAGES: ${{ steps.publish.outputs.command-output }}
PUBLISH_CFPAGES_URL: ${{ steps.publish.outputs.deployment-url }}
+ PUBLISH_CFPAGES_ALIAS: ${{ steps.generate-alias-url.outputs.alias }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `\n#### Cloudflare Pages set production branch ⚙️\`${{ steps.set-production-branch.outcome }}\`\n
#### Cloudflare Pages Deploy 📖\`${{ steps.publish.outcome }}\`\n
- 🔗 [Cloudflare Pages Deploy URL](${process.env.PUBLISH_CFPAGES_URL})\n
+ 🔗 ${process.env.PUBLISH_CFPAGES_URL}(${process.env.PUBLISH_CFPAGES_URL})\n
+
+ if (process.env.PUBLISH_CFPAGES_ALIAS) {
+ `📌 Alias URL: ${process.env.PUBLISH_CFPAGES_ALIAS}(${process.env.PUBLISH_CFPAGES_ALIAS})\n`;
+ }
Deploying with Cloudflare Pages