generated from namidapoo/next15-shadcn-use-bun
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
341 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Approve Me | ||
|
||
on: | ||
issue_comment: | ||
types: [created, edited] | ||
|
||
jobs: | ||
approve: | ||
name: Approve | ||
if: | | ||
github.event.issue.state == 'open' && | ||
github.event.issue.pull_request != null && | ||
contains(github.event.comment.body, '@github-actions approve me') && | ||
(github.event.action != 'edited' || (github.event.action == 'edited' && !contains(github.event.changes.body.from, '@github-actions approve me'))) | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Approve pull request | ||
env: | ||
GH_REPO: ${{ github.repository }} | ||
GH_TOKEN: ${{ github.token }} | ||
run: | | ||
gh pr review ${{ github.event.issue.number }} --approve |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: Auto Assign PR | ||
|
||
on: | ||
pull_request: | ||
types: [opened, unassigned] | ||
|
||
permissions: | ||
pull-requests: write | ||
repository-projects: read | ||
|
||
jobs: | ||
assign: | ||
name: PR automation | ||
timeout-minutes: 1 | ||
if: ${{ ! contains(fromJson('["renovate[bot]", "dependabot[bot]"]'), github.actor) }} | ||
runs-on: ubuntu-22.04 | ||
# コミットが重なった時同時に実行されないように、進行中のジョブをキャンセルするように設定する。 | ||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
steps: | ||
- name: Set GitHub assignees | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
run: gh pr edit ${{ github.event.number }} --add-assignee ${{ github.actor }} --repo ${{ github.repository }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
name: "conflict-finder" | ||
on: | ||
push: | ||
jobs: | ||
triage: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: hcancelik/pr-conflict-finder@v1.0.6 | ||
with: | ||
secret_token: ${{ secrets.GITHUB_TOKEN }} | ||
conflict_label: "conflict" | ||
max_tries: 5 | ||
wait_ms: 5000 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,137 @@ | ||
name: Deployment Info Comment on PR | ||
|
||
on: | ||
pull_request: | ||
types: [opened] | ||
|
||
jobs: | ||
comment_on_pr: | ||
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
steps: | ||
- name: Checkout PR branch | ||
uses: actions/checkout@v4 | ||
|
||
- name: Wait for 3 seconds | ||
run: sleep 3 | ||
|
||
- name: Check if Deploy Workflow is Running | ||
id: check_deploy | ||
run: | | ||
runs=$(gh run list --branch ${{ github.head_ref }} --workflow "Deploy to Cloudflare Pages" --json status --jq '.[] | select(.status == "in_progress")') | ||
if [[ -n "$runs" ]]; then | ||
echo "Deploy workflow is currently running. Exiting." | ||
echo "DEPLOY_STATUS=running" >> $GITHUB_ENV | ||
exit 0 | ||
else | ||
echo "DEPLOY_STATUS=completed" >> $GITHUB_ENV | ||
fi | ||
- name: Add to Job Summaries if Deployment Running | ||
if: env.DEPLOY_STATUS == 'running' | ||
run: echo "✅ This workflow ended without executing anything because the deployment workflow was running." >> "$GITHUB_STEP_SUMMARY" | ||
|
||
- name: Get Latest Commit Hash | ||
if: env.DEPLOY_STATUS == 'completed' | ||
id: get_commit | ||
run: | | ||
COMMIT_HASH=$(gh pr view ${{ github.event.pull_request.number }} --json commits -q ".commits[-1].oid") | ||
echo "COMMIT_HASH=${COMMIT_HASH}" >> $GITHUB_ENV | ||
SHORT_COMMIT_HASH=${COMMIT_HASH:0:7} | ||
echo "SHORT_COMMIT_HASH=${SHORT_COMMIT_HASH}" >> $GITHUB_ENV | ||
- name: Output Latest Commit Hash | ||
if: env.DEPLOY_STATUS == 'completed' | ||
run: echo "Latest Commit Hash ... ${{ env.COMMIT_HASH }}" | ||
|
||
- name: Fetch latest deployment info and match with commit hash | ||
if: env.DEPLOY_STATUS == 'completed' | ||
env: | ||
CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
CLOUDFLARE_PROJECT_NAME: ${{ secrets.CLOUDFLARE_PROJECT_NAME }} | ||
run: | | ||
response=$(curl -s -X GET "https://api.cloudflare.com/client/v4/accounts/$CLOUDFLARE_ACCOUNT_ID/pages/projects/$CLOUDFLARE_PROJECT_NAME/deployments" \ | ||
-H "Authorization: Bearer $CLOUDFLARE_API_TOKEN" \ | ||
-H "Content-Type: application/json") | ||
matching_deployment=$(echo "$response" | jq -r --arg commit "${{ env.COMMIT_HASH }}" '.result[] | select(.deployment_trigger.metadata.commit_hash == $commit)') | ||
if [ -z "$matching_deployment" ]; then | ||
echo "No deployment found for the latest commit hash." | ||
exit 1 | ||
fi | ||
deployment_url=$(echo "$matching_deployment" | jq -r '.url') | ||
deployment_alias_url=$(echo "$matching_deployment" | jq -r '.aliases[0]') | ||
pages_deployment_id=$(echo "$matching_deployment" | jq -r '.id') | ||
echo "Matched Deploy URL: $deployment_url" | ||
echo "Deploy Alias URL: $deployment_alias_url" | ||
echo "Deploy ID: $pages_deployment_id" | ||
echo "LATEST_DEPLOY_URL=$deployment_url" >> $GITHUB_ENV | ||
echo "DEPLOY_ALIAS_URL=$deployment_alias_url" >> $GITHUB_ENV | ||
echo "DEPLOY_ID=$pages_deployment_id" >> $GITHUB_ENV | ||
- name: Create Comment Content | ||
if: env.DEPLOY_STATUS == 'completed' | ||
run: | | ||
{ | ||
echo "GH_SAMPLE_COMMENT<<EOF" | ||
echo "<!-- DEPLOYMENT_COMMENT -->" | ||
echo "## Deploying ${{ secrets.CLOUDFLARE_PROJECT_NAME }} with <a href='https://pages.dev'><img alt='Cloudflare Pages' src='https://user-images.githubusercontent.com/23264/106598434-9e719e00-654f-11eb-9e59-6167043cfa01.png' width='16'></a> Cloudflare Pages" | ||
echo "" | ||
echo "<table><tr><td><strong>Latest commit:</strong> </td><td>" | ||
echo "<code>${{ env.SHORT_COMMIT_HASH }}</code>" | ||
echo "</td></tr>" | ||
echo "<tr><td><strong>Status:</strong></td><td> ✅ Deploy successful!</td></tr>" | ||
echo "<tr><td><strong>Preview URL:</strong></td><td>" | ||
echo "<a href='${{ env.LATEST_DEPLOY_URL }}'>${{ env.LATEST_DEPLOY_URL }}</a>" | ||
echo "</td></tr>" | ||
echo "<tr><td><strong>Branch Preview URL:</strong></td><td>" | ||
echo "<a href='${{ env.DEPLOY_ALIAS_URL }}'>${{ env.DEPLOY_ALIAS_URL }}</a>" | ||
echo "</td></tr>" | ||
echo "</table>" | ||
echo "" | ||
echo "[View logs](https://dash.cloudflare.com/?to=/:account/pages/view/${{ secrets.CLOUDFLARE_PROJECT_NAME }}/${{ env.DEPLOY_ID }})" | ||
echo "EOF" | ||
} >> "$GITHUB_ENV" | ||
- name: Add or Update Comment on Pull Request | ||
if: env.DEPLOY_STATUS == 'completed' | ||
run: | | ||
PR_NUMBER=${{ github.event.pull_request.number }} | ||
# Fetch existing comments | ||
COMMENTS=$(gh api repos/${{ github.repository }}/issues/${PR_NUMBER}/comments --jq '.[] | @base64') | ||
COMMENT_ID="" | ||
for COMMENT in $COMMENTS; do | ||
COMMENT_JSON=$(echo $COMMENT | base64 --decode) | ||
BODY=$(echo $COMMENT_JSON | jq -r '.body') | ||
ID=$(echo $COMMENT_JSON | jq -r '.id') | ||
if echo "$BODY" | grep -q '<!-- DEPLOYMENT_COMMENT -->'; then | ||
COMMENT_ID=$ID | ||
break | ||
fi | ||
done | ||
if [ -n "$COMMENT_ID" ]; then | ||
echo "Updating existing comment ID: $COMMENT_ID" | ||
gh api \ | ||
--method PATCH \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
/repos/${{ github.repository }}/issues/comments/$COMMENT_ID \ | ||
-f body="${{ env.GH_SAMPLE_COMMENT }}" | ||
else | ||
echo "Creating new comment" | ||
gh pr comment $PR_NUMBER --body "${{ env.GH_SAMPLE_COMMENT }}" | ||
fi | ||
- name: Add to Job Summaries | ||
if: env.DEPLOY_STATUS == 'completed' | ||
run: echo "${{ env.GH_SAMPLE_COMMENT }}" >> "$GITHUB_STEP_SUMMARY" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
name: Deploy to Cloudflare Pages | ||
|
||
on: | ||
push: | ||
branches: | ||
- "**" | ||
|
||
jobs: | ||
deploy: | ||
runs-on: ubuntu-latest | ||
env: | ||
GH_TOKEN: ${{ github.token }} | ||
steps: | ||
- name: Checkout Repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Get Latest Commit Hash | ||
id: get_commit | ||
run: echo "COMMIT_HASH=$(git rev-parse --short=7 HEAD)" >> $GITHUB_ENV | ||
|
||
- name: Setup Bun Environment | ||
uses: oven-sh/setup-bun@v2.0.1 | ||
|
||
- name: Install Project Dependencies | ||
run: bun i | ||
|
||
- name: Build Project with Bun | ||
run: bunx @cloudflare/next-on-pages | ||
|
||
- name: Deploy to Cloudflare Pages with Wrangler | ||
id: deploy | ||
uses: cloudflare/wrangler-action@v3 | ||
with: | ||
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | ||
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | ||
command: pages deploy .vercel/output/static --project-name=${{ secrets.CLOUDFLARE_PROJECT_NAME }} | ||
|
||
- name: Create Comment Content | ||
run: | | ||
{ | ||
echo "GH_SAMPLE_COMMENT<<EOF" | ||
echo "<!-- DEPLOYMENT_COMMENT -->" | ||
echo "## Deploying ${{ secrets.CLOUDFLARE_PROJECT_NAME }} with <a href='https://pages.dev'><img alt='Cloudflare Pages' src='https://user-images.githubusercontent.com/23264/106598434-9e719e00-654f-11eb-9e59-6167043cfa01.png' width='16'></a> Cloudflare Pages" | ||
echo "" | ||
echo "<table><tr><td><strong>Latest commit:</strong> </td><td>" | ||
echo "<code>${{ env.COMMIT_HASH }}</code>" | ||
echo "</td></tr>" | ||
echo "<tr><td><strong>Status:</strong></td><td> ✅ Deploy successful!</td></tr>" | ||
echo "<tr><td><strong>Preview URL:</strong></td><td>" | ||
echo "<a href='${{ steps.deploy.outputs.deployment-url }}'>${{ steps.deploy.outputs.deployment-url }}</a>" | ||
echo "</td></tr>" | ||
echo "<tr><td><strong>Branch Preview URL:</strong></td><td>" | ||
echo "<a href='${{ steps.deploy.outputs.deployment-alias-url }}'>${{ steps.deploy.outputs.deployment-alias-url }}</a>" | ||
echo "</td></tr>" | ||
echo "</table>" | ||
echo "" | ||
echo "[View logs](https://dash.cloudflare.com/?to=/:account/pages/view/${{ secrets.CLOUDFLARE_PROJECT_NAME }}/${{ steps.deploy.outputs.pages-deployment-id }})" | ||
echo "EOF" | ||
} >> "$GITHUB_ENV" | ||
- name: Check if PR exists | ||
id: check_pr | ||
run: | | ||
if gh pr list --head "${{ github.ref_name }}" --json number --jq '. | length' | grep -q '1'; then | ||
echo "PR_EXISTS=true" >> $GITHUB_ENV | ||
else | ||
echo "PR_EXISTS=false" >> $GITHUB_ENV | ||
fi | ||
- name: Add or Update Comment on Pull Request | ||
if: env.PR_EXISTS == 'true' | ||
run: | | ||
PR_NUMBER=$(gh pr list --head "${{ github.ref_name }}" --json number -q '.[0].number') | ||
# Fetch existing comments | ||
COMMENTS=$(gh api repos/${{ github.repository }}/issues/${PR_NUMBER}/comments --jq '.[] | @base64') | ||
COMMENT_ID="" | ||
for COMMENT in $COMMENTS; do | ||
COMMENT_JSON=$(echo $COMMENT | base64 --decode) | ||
BODY=$(echo $COMMENT_JSON | jq -r '.body') | ||
ID=$(echo $COMMENT_JSON | jq -r '.id') | ||
if echo "$BODY" | grep -q '<!-- DEPLOYMENT_COMMENT -->'; then | ||
COMMENT_ID=$ID | ||
break | ||
fi | ||
done | ||
if [ -n "$COMMENT_ID" ]; then | ||
echo "Updating existing comment ID: $COMMENT_ID" | ||
gh api \ | ||
--method PATCH \ | ||
-H "Accept: application/vnd.github.v3+json" \ | ||
/repos/${{ github.repository }}/issues/comments/$COMMENT_ID \ | ||
-f body="${{ env.GH_SAMPLE_COMMENT }}" | ||
else | ||
echo "Creating new comment" | ||
gh pr comment $PR_NUMBER --body "${{ env.GH_SAMPLE_COMMENT }}" | ||
fi | ||
- name: Add to Job Summaries | ||
run: echo "${{ env.GH_SAMPLE_COMMENT }}" >> "$GITHUB_STEP_SUMMARY" |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
name: Find TODOs in pull requests | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
find-todos: | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: indigo-san/todo-comments-in-pr@v1 | ||
id: todos | ||
|
||
- name: Generate a summary of the tasks | ||
uses: actions/github-script@v7 | ||
id: summary | ||
with: | ||
result-encoding: string | ||
script: | | ||
const tasks = JSON.parse(String.raw`${{ steps.todos.outputs.tasks }}`); | ||
let body = tasks.map(task => `https://github.com/${{ github.repository }}/blob/${{ github.sha }}/${task.fileName}#L${task.startLine}-L${task.endLine}`).join('\n'); | ||
if (tasks.length > 0) { | ||
body = `以下のTODOコメントが見つかりました:\n\n${body}`; | ||
} else { | ||
body = 'TODOコメントは見つかりませんでした。'; | ||
} | ||
return body; | ||
- name: Comment on the pull request | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: todo-cooments | ||
recreate: true | ||
message: | | ||
${{ steps.summary.outputs.result }} |