Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 16 additions & 25 deletions .github/workflows/deploy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ on:
push:
branches:
- main
pull_request:
permissions:
contents: read
pull-requests: write
jobs:
deploy:
runs-on: ubuntu-latest
Expand All @@ -22,49 +26,36 @@ jobs:
run: bun run build

- name: Deploy Worker
id: deploy-worker
uses: cloudflare/wrangler-action@v3
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}


- name: print deployment-url
- name: Print deployment url
if: ${{ steps.deploy-worker.outputs.deployment-url }}
env:
DEPLOYMENT_URL: ${{ steps.deploy-pages-preview.outputs.deployment-url }}
STORYBOOK_DEPLOYMENT_URL: ${{ steps.deploy-storybook-preview.outputs.deployment-url }}
STORYBOOK_BRANCH_URL: ${{ steps.deploy-storybook-preview.outputs.deployment-alias-url }}
run: |
echo $DEPLOYMENT_URL
echo $STORYBOOK_DEPLOYMENT_URL
echo $STORYBOOK_BRANCH_URL
DEPLOYMENT_URL: ${{ steps.deploy-worker.outputs.deployment-url }}
run: echo "Deployment URL: $DEPLOYMENT_URL"

- name: Create comment file
id: create-comment-file
if: ${{ github.event_name == 'pull_request' && steps.deploy-worker.outputs.deployment-url }}
env:
DEPLOYMENT_URL: ${{ steps.deploy-pages-preview.outputs.deployment-url }}
STORYBOOK_DEPLOYMENT_URL: ${{ steps.deploy-storybook-preview.outputs.deployment-url }}
STORYBOOK_BRANCH_URL: ${{ steps.deploy-storybook-preview.outputs.deployment-alias-url }}
DEPLOYMENT_URL: ${{ steps.deploy-worker.outputs.deployment-url }}
REPO_NAME: ${{ github.event.repository.name }}
run: |
cat << EOF > comment.md
## 🚀 Deploying ${{ github.event.repository.name }} with Cloudflare Workers
## 🚀 Deploying $REPO_NAME with Cloudflare Workers
<table>
<tr>
<th scope="row">Preview URL</th>
<td><a href="$DEPLOYMENT_URL" target="_blank" rel="noopener noreferrer">$DEPLOYMENT_URL</a></td>
</tr>
<tr>
<th scope="row">Storybook Preview URL</th>
<td><a href="$STORYBOOK_DEPLOYMENT_URL" target="_blank" rel="noopener noreferrer">$STORYBOOK_DEPLOYMENT_URL</a></td>
</tr>
<tr>
<th scope="row">Storybook branch URL</th>
<td><a href="$STORYBOOK_BRANCH_URL" target="_blank" rel="noopener noreferrer">$STORYBOOK_BRANCH_URL</a></td>
</tr>
</table>
EOF

- name: Create PR comment
if: ${{ steps.deploy-pages-preview.outcome == 'success' && steps.deploy-storybook-preview.outcome == 'success' }}
run: gh pr comment ${{ github.event.number }} --body-file comment.md
if: ${{ github.event_name == 'pull_request' && steps.deploy-worker.outputs.deployment-url }}
run: gh pr comment ${{ github.event.pull_request.number }} --body-file comment.md
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}