Skip to content

Commit ab1fe98

Browse files
committed
chore: provision backfill workflow
1 parent 731d74c commit ab1fe98

1 file changed

Lines changed: 55 additions & 0 deletions

File tree

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Backfill
2+
on:
3+
workflow_dispatch:
4+
inputs:
5+
branch:
6+
required: true
7+
default: main
8+
author_name:
9+
required: false
10+
default: Heatmap Bot
11+
author_email:
12+
required: false
13+
dates_json:
14+
required: true
15+
message:
16+
required: false
17+
default: Backfill
18+
permissions:
19+
contents: write
20+
jobs:
21+
run:
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
ref: ${{inputs.branch}}
28+
- uses: actions/setup-node@v4
29+
with:
30+
node-version: 20
31+
- name: Backfill commits
32+
shell: bash
33+
env:
34+
DATES_JSON: ${{inputs.dates_json}}
35+
BRANCH: ${{inputs.branch}}
36+
AUTHOR_NAME: ${{inputs.author_name}}
37+
AUTHOR_EMAIL: ${{inputs.author_email}}
38+
DEFAULT_NO_REPLY: ${{github.actor}}@users.noreply.github.com
39+
MSG_PREFIX: ${{inputs.message}}
40+
run: |
41+
set -e
42+
NAME="${AUTHOR_NAME:-Heatmap Bot}"
43+
EMAIL="${AUTHOR_EMAIL:-$DEFAULT_NO_REPLY}"
44+
git config user.name "$NAME"
45+
git config user.email "$EMAIL"
46+
echo "$DATES_JSON" > dates.json
47+
node -e 'const fs=require("fs"); const d=JSON.parse(fs.readFileSync("dates.json","utf8")); console.log(d.join("\n"));' > dates.txt
48+
while IFS= read -r ymd; do
49+
[ -z "$ymd" ] && continue
50+
mkdir -p daily
51+
echo "Backfill commit for $ymd" > "daily/$ymd.txt"
52+
git add .
53+
GIT_AUTHOR_DATE="${ymd}T12:00:00" GIT_COMMITTER_DATE="${ymd}T12:00:00" git commit -m "${MSG_PREFIX:-Backfill} ${ymd}" --allow-empty --date "${ymd}T12:00:00"
54+
done < dates.txt
55+
git push origin HEAD:$BRANCH

0 commit comments

Comments
 (0)