mirror of
https://github.com/andwati/andwati.com.git
synced 2026-11-20 23:48:49 +00:00
Compare commits
13
Commits
feat/nextjs-site
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d423bba15e | ||
|
|
694f65faad
|
||
|
|
c7177720f9 | ||
|
|
12f84af823
|
||
|
|
dc0b223025 | ||
|
|
d931b47af2
|
||
|
|
dd6cc9b223 | ||
|
|
e0f0ae7c7f
|
||
|
|
203ead6ef5 | ||
|
|
2c19e7ed1a | ||
|
|
a06a93019f | ||
|
|
77cc86ddf9 | ||
|
|
2960dc622f |
@@ -0,0 +1,85 @@
|
|||||||
|
name: Delete stale branches
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 3 * * 1"
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
days:
|
||||||
|
description: Days without commits before a branch is stale
|
||||||
|
default: "60"
|
||||||
|
dry_run:
|
||||||
|
description: List stale branches without deleting them
|
||||||
|
type: boolean
|
||||||
|
default: false
|
||||||
|
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pull-requests: read
|
||||||
|
|
||||||
|
env:
|
||||||
|
PROTECTED_BRANCHES: main staging prod master
|
||||||
|
STALE_DAYS: ${{ inputs.days || '60' }}
|
||||||
|
DRY_RUN: ${{ github.event_name == 'workflow_dispatch' && inputs.dry_run || 'false' }}
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
delete-stale-branches:
|
||||||
|
name: Delete stale branches
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Ensure gh and jq are installed
|
||||||
|
env:
|
||||||
|
GH_VERSION: "2.63.2"
|
||||||
|
JQ_VERSION: "1.7.1"
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
case "$(uname -m)" in
|
||||||
|
x86_64) arch=amd64 ;;
|
||||||
|
aarch64|arm64) arch=arm64 ;;
|
||||||
|
*) echo "unsupported architecture: $(uname -m)"; exit 1 ;;
|
||||||
|
esac
|
||||||
|
bin="$RUNNER_TEMP/bin"
|
||||||
|
mkdir -p "$bin"
|
||||||
|
if ! command -v jq >/dev/null 2>&1; then
|
||||||
|
curl -fsSL -o "$bin/jq" "https://github.com/jqlang/jq/releases/download/jq-${JQ_VERSION}/jq-linux-${arch}"
|
||||||
|
chmod +x "$bin/jq"
|
||||||
|
fi
|
||||||
|
if ! command -v gh >/dev/null 2>&1; then
|
||||||
|
curl -fsSL "https://github.com/cli/cli/releases/download/v${GH_VERSION}/gh_${GH_VERSION}_linux_${arch}.tar.gz" | tar -xz -C "$RUNNER_TEMP"
|
||||||
|
cp "$RUNNER_TEMP/gh_${GH_VERSION}_linux_${arch}/bin/gh" "$bin/gh"
|
||||||
|
fi
|
||||||
|
echo "$bin" >> "$GITHUB_PATH"
|
||||||
|
PATH="$bin:$PATH"
|
||||||
|
gh --version | head -1
|
||||||
|
jq --version
|
||||||
|
|
||||||
|
- name: Delete branches with no recent activity
|
||||||
|
env:
|
||||||
|
GH_TOKEN: ${{ github.token }}
|
||||||
|
REPO: ${{ github.repository }}
|
||||||
|
run: |
|
||||||
|
set -euo pipefail
|
||||||
|
default_branch=$(gh api "repos/$REPO" --jq .default_branch)
|
||||||
|
cutoff=$(date -u -d "$STALE_DAYS days ago" +%s)
|
||||||
|
open_heads=$(gh pr list --repo "$REPO" --state open --limit 1000 --json headRefName --jq '.[].headRefName')
|
||||||
|
|
||||||
|
gh api --paginate "repos/$REPO/branches?per_page=100" --jq '.[] | select(.protected | not) | .name' |
|
||||||
|
while read -r branch; do
|
||||||
|
if [ "$branch" = "$default_branch" ] || [[ " $PROTECTED_BRANCHES " == *" $branch "* ]]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if grep -qxF -- "$branch" <<< "$open_heads"; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
encoded=$(jq -rn --arg b "$branch" '$b | @uri')
|
||||||
|
committed=$(gh api "repos/$REPO/commits/$encoded" --jq .commit.committer.date)
|
||||||
|
if [ "$(date -u -d "$committed" +%s)" -ge "$cutoff" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ "$DRY_RUN" = "true" ]; then
|
||||||
|
echo "would delete $branch (last commit $committed)"
|
||||||
|
else
|
||||||
|
echo "deleting $branch (last commit $committed)"
|
||||||
|
gh api -X DELETE "repos/$REPO/git/refs/heads/$encoded"
|
||||||
|
fi
|
||||||
|
done
|
||||||
+18
-1
@@ -58,6 +58,9 @@ const websiteLd = {
|
|||||||
author: { "@type": "Person", name: site.name },
|
author: { "@type": "Person", name: site.name },
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const isProd = process.env.NODE_ENV === "production";
|
||||||
|
const gaId = "G-9XLTKZF07C";
|
||||||
|
|
||||||
const umamiScript = process.env.PUBLIC_UMAMI_SCRIPT_URL;
|
const umamiScript = process.env.PUBLIC_UMAMI_SCRIPT_URL;
|
||||||
const umamiId = process.env.PUBLIC_UMAMI_WEBSITE_ID;
|
const umamiId = process.env.PUBLIC_UMAMI_WEBSITE_ID;
|
||||||
|
|
||||||
@@ -81,7 +84,21 @@ export default function RootLayout({ children }: LayoutProps<"/">) {
|
|||||||
<body>
|
<body>
|
||||||
<JsonLd data={websiteLd} />
|
<JsonLd data={websiteLd} />
|
||||||
<Layout>{children}</Layout>
|
<Layout>{children}</Layout>
|
||||||
{umamiScript && umamiId && (
|
{isProd && (
|
||||||
|
<>
|
||||||
|
<Script
|
||||||
|
src={`https://www.googletagmanager.com/gtag/js?id=${gaId}`}
|
||||||
|
strategy="afterInteractive"
|
||||||
|
/>
|
||||||
|
<Script id="google-analytics" strategy="afterInteractive">
|
||||||
|
{`window.dataLayer = window.dataLayer || [];
|
||||||
|
function gtag(){dataLayer.push(arguments);}
|
||||||
|
gtag('js', new Date());
|
||||||
|
gtag('config', '${gaId}');`}
|
||||||
|
</Script>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
{isProd && umamiScript && umamiId && (
|
||||||
<Script defer src={umamiScript} data-website-id={umamiId} />
|
<Script defer src={umamiScript} data-website-id={umamiId} />
|
||||||
)}
|
)}
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@@ -7,10 +7,67 @@ ignore-hidden-files = false
|
|||||||
|
|
||||||
[advanced]
|
[advanced]
|
||||||
|
|
||||||
|
# Legacy Hugo URLs (/posts, /writings, /tags, ...) -> current routes. First match wins,
|
||||||
|
# so the trailing-slash variants Google crawled come before the bare ones.
|
||||||
|
[[advanced.redirects]]
|
||||||
|
source = "/posts/page/{*}/"
|
||||||
|
destination = "/writing"
|
||||||
|
kind = 301
|
||||||
|
|
||||||
|
[[advanced.redirects]]
|
||||||
|
source = "/posts/page/{*}"
|
||||||
|
destination = "/writing"
|
||||||
|
kind = 301
|
||||||
|
|
||||||
|
[[advanced.redirects]]
|
||||||
|
source = "/{posts,writings,tags,archive}/"
|
||||||
|
destination = "/writing"
|
||||||
|
kind = 301
|
||||||
|
|
||||||
|
[[advanced.redirects]]
|
||||||
|
source = "/{posts,writings}/{*}/"
|
||||||
|
destination = "/writing/$2"
|
||||||
|
kind = 301
|
||||||
|
|
||||||
|
[[advanced.redirects]]
|
||||||
|
source = "/{posts,writings}/{*}"
|
||||||
|
destination = "/writing/$2"
|
||||||
|
kind = 301
|
||||||
|
|
||||||
|
[[advanced.redirects]]
|
||||||
|
source = "/{posts,writings,tags,archive}"
|
||||||
|
destination = "/writing"
|
||||||
|
kind = 301
|
||||||
|
|
||||||
|
[[advanced.redirects]]
|
||||||
|
source = "/tags/{*}/"
|
||||||
|
destination = "/writing"
|
||||||
|
kind = 301
|
||||||
|
|
||||||
|
[[advanced.redirects]]
|
||||||
|
source = "/tags/{*}"
|
||||||
|
destination = "/writing"
|
||||||
|
kind = 301
|
||||||
|
|
||||||
|
[[advanced.redirects]]
|
||||||
|
source = "/about/"
|
||||||
|
destination = "/"
|
||||||
|
kind = 301
|
||||||
|
|
||||||
|
[[advanced.redirects]]
|
||||||
|
source = "/about"
|
||||||
|
destination = "/"
|
||||||
|
kind = 301
|
||||||
|
|
||||||
|
[[advanced.redirects]]
|
||||||
|
source = "/index.xml"
|
||||||
|
destination = "/rss.xml"
|
||||||
|
kind = 301
|
||||||
|
|
||||||
[[advanced.headers]]
|
[[advanced.headers]]
|
||||||
source = "**"
|
source = "**"
|
||||||
[advanced.headers.headers]
|
[advanced.headers.headers]
|
||||||
Content-Security-Policy = "default-src 'self'; script-src 'self' 'unsafe-inline' https://utteranc.es https://analytics.andwati.com; style-src 'self' 'unsafe-inline'; img-src 'self' data:; font-src 'self'; connect-src 'self' https://analytics.andwati.com; frame-src https://www.youtube-nocookie.com https://utteranc.es; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests"
|
Content-Security-Policy = "default-src 'self'; script-src 'self' 'unsafe-inline' https://utteranc.es https://analytics.andwati.com https://www.googletagmanager.com https://static.cloudflareinsights.com; style-src 'self' 'unsafe-inline'; img-src 'self' data: https://www.google-analytics.com https://www.googletagmanager.com; font-src 'self'; connect-src 'self' https://cloudflareinsights.com https://analytics.andwati.com https://www.google-analytics.com https://*.google-analytics.com https://*.analytics.google.com https://www.googletagmanager.com; frame-src https://www.youtube-nocookie.com https://utteranc.es; object-src 'none'; base-uri 'self'; form-action 'self'; frame-ancestors 'none'; upgrade-insecure-requests"
|
||||||
X-Frame-Options = "DENY"
|
X-Frame-Options = "DENY"
|
||||||
X-Content-Type-Options = "nosniff"
|
X-Content-Type-Options = "nosniff"
|
||||||
Referrer-Policy = "strict-origin-when-cross-origin"
|
Referrer-Policy = "strict-origin-when-cross-origin"
|
||||||
|
|||||||
Reference in New Issue
Block a user