ci(deps): bump cloudflare/wrangler-action from 3.12.1 to 3.13.0 #5734
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Cloudflare Pages | |
env: | |
#CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
#CLOUDFLARE_ACCOUNT_ID: ${{ vars.CLOUDFLARE_ACCOUNT_ID }} | |
#CLOUDFLARE_PROJECT_NAME: ${{ vars.CLOUDFLARE_PROJECT_NAME }} | |
CLOUDFLARE_DIRECTORY: _site | |
# tool versions | |
# renovate: datasource=npm depName=wrangler | |
WRANGLER_VERSION: 3.91.0 | |
on: | |
push: | |
branches: ["**"] | |
# マージ コミットのコンテキストではなく、pull request のベースのコンテキストで実行されます。 | |
pull_request_target: | |
permissions: {} | |
jobs: | |
pre-deployment: | |
if: ${{ vars.CLOUDFLARE_PROJECT_NAME != '' }} | |
outputs: | |
branch: ${{ steps.get.outputs.branch }} | |
environment: ${{ steps.get.outputs.environment }} | |
runs-on: ubuntu-latest | |
steps: | |
- id: get | |
run: | | |
if ${{ github.event_name == 'push' }}; then | |
echo "branch=${{ github.ref_name }}" >> "$GITHUB_OUTPUT" | |
elif ${{ github.event_name == 'pull_request_target' }}; then | |
echo "branch=pull/${{ github.event.number }}/merge" >> "$GITHUB_OUTPUT" | |
if ${{ github.event.pull_request.head.repo.html_url != github.event.repository.html_url }}; then | |
echo "environment=External PR" >> "$GITHUB_OUTPUT" | |
fi | |
else | |
exit 1 | |
fi | |
deployment: | |
needs: ["pre-deployment"] | |
env: | |
BRANCH: ${{ needs.pre-deployment.outputs.branch }} | |
runs-on: ubuntu-latest | |
environment: | |
name: ${{ needs.pre-deployment.outputs.environment }} | |
url: ${{ steps.deploy.outputs.deployment-url }} | |
permissions: | |
contents: read | |
deployments: write | |
pull-requests: write | |
steps: | |
- id: pr-checkout | |
if: startsWith( needs.pre-deployment.outputs.branch, 'pull/' ) && endsWith( needs.pre-deployment.outputs.branch, '/merge' ) | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
ref: refs/${{ env.BRANCH }} | |
- if: steps.pr-checkout.conclusion == 'skipped' | |
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 | |
with: | |
ref: ${{ env.BRANCH }} | |
- run: mkdir _site && cp test _site/index.html | |
- name: Install pnpm | |
uses: pnpm/action-setup@fe02b34f77f8bc703788d5817da081398fad5dd2 # v4.0.0 | |
- id: deploy | |
name: Deploy | |
uses: cloudflare/wrangler-action@6d58852c35a27e6034745c5d0bc373d739014f7f # v3.13.0 | |
with: | |
wranglerVersion: ${{ env.WRANGLER_VERSION }} | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ vars.CLOUDFLARE_ACCOUNT_ID }} | |
command: pages deploy ${{ env.CLOUDFLARE_DIRECTORY }} --project-name=${{ vars.CLOUDFLARE_PROJECT_NAME }} --branch=${{ env.BRANCH }} | |
- run: echo "$output" >> $GITHUB_STEP_SUMMARY | |
env: | |
output: ${{ steps.deploy.outputs.command-output }} | |
- if: ${{ ! cancelled() && github.event_name == 'pull_request_target' }} | |
uses: peter-evans/find-comment@3eae4d37986fb5a8592848f6a574fdf654e61f9e # v3.1.0 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: "github-actions[bot]" | |
body-includes: DEPLOYMENT_COMMENT | |
- id: comment-data | |
if: steps.fc.conclusion == 'success' | |
run: | | |
head_sha=$(git rev-parse HEAD) | |
get_short_sha_with_link() { | |
echo "<a href='${{ github.event.repository.html_url }}/commit/$1'><code>$(echo "$1" | head -c 7)</code></a>" | |
} | |
echo "commit_text=$(get_short_sha_with_link $(git rev-parse HEAD)) ( base: $(get_short_sha_with_link ${{ github.event.pull_request.base.sha }}) + head: $(get_short_sha_with_link ${{ github.event.pull_request.head.sha }}) )" >> "$GITHUB_OUTPUT" | |
- if: steps.fc.conclusion == 'success' | |
uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
<!-- DEPLOYMENT_COMMENT --> | |
<table><tr><td><strong>Latest commit:</strong> </td><td> | |
${{ steps.comment-data.outputs.commit_text }} | |
</td></tr> | |
<tr><td><strong>Status:</strong></td><td> ✅ Deploy successful!</td></tr> | |
<tr><td><strong>Preview URL:</strong></td><td> | |
<a href='${{ steps.deploy.outputs.deployment-url }}'>${{ steps.deploy.outputs.deployment-url }}</a> | |
</td></tr> | |
<tr><td><strong>PR Preview URL:</strong></td><td> | |
<a href='${{ steps.deploy.outputs.pages-pages-deployment-alias-url }}'>${{ steps.deploy.outputs.pages-pages-deployment-alias-url }}</a> | |
</td></tr> | |
</table> | |
[View workflow logs](${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}) | |
[View Cloudflare logs](https://dash.cloudflare.com/?to=/${{ vars.CLOUDFLARE_ACCOUNT_ID }}/pages/view/${{ vars.CLOUDFLARE_PROJECT_NAME }}/) | |
edit-mode: replace | |
- uses: peter-evans/create-or-update-comment@71345be0265236311c031f5c7866368bd1eff043 # v4.0.0 | |
if: failure() && steps.fc.conclusion == 'success' | |
with: | |
token: ${{ secrets.GITHUB_TOKEN}} | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
body: | | |
<!-- DEPLOYMENT_COMMENT --> | |
<table><tr><td><strong>Latest commit:</strong> </td><td> | |
${{ steps.comment-data.outputs.commit_text }} | |
</td></tr> | |
<tr><td><strong>Status:</strong></td><td> ❌ Deploy failed!</td></tr> | |
</table> | |
[View workflow logs](${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}) | |
[View Cloudflare logs](https://dash.cloudflare.com/?to=/${{ vars.CLOUDFLARE_ACCOUNT_ID }}/pages/view/${{ vars.CLOUDFLARE_PROJECT_NAME }}/) | |
edit-mode: replace |