-
Notifications
You must be signed in to change notification settings - Fork 0
161 lines (151 loc) · 6.97 KB
/
Copy pathtrack.yml
File metadata and controls
161 lines (151 loc) · 6.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
# Tracks a contribution-art plan and comments the report on issue #1.
#
# The plan is a heart across the closing weeks of 2026: seven rows by
# eleven columns, drawn from Sunday 30 August to 14 November. See
# heart.art, which is the picture itself and readable as one.
#
# Copied from vyncint/mossaic action/track.example.yml with the `with:` block
# edited; the channels needing secrets are left in, gated off by repository
# variables, so turning one on is a switch rather than an edit.
#
# Dispatch-only: the twice-daily schedule is commented out in `on:` below, so
# the plan is tracked when this workflow is run by hand and not otherwise.
name: contribution art
on:
# Scheduled runs are disabled. Uncomment the block below to restore them.
# schedule:
# # UTC. 01:00 UTC is 08:00 in UTC+7 — morning report.
# - cron: "0 1 * * *"
# # 16:30 UTC is 23:30 in UTC+7 — late evening check & auto-commit.
# - cron: "30 16 * * *"
# So you can run it now instead of waiting for tomorrow, with optional auto-commit.
workflow_dispatch:
inputs:
auto_commit:
description: "Auto-commit missing contributions for today"
type: boolean
default: false
permissions:
contents: write
# Only needed by the issue-comment step below.
issues: write
jobs:
track:
runs-on: ubuntu-latest
steps:
# `matrix` is a path in this repository, so the picture has to be
# checked out before the action can read it.
- uses: actions/checkout@v4
with:
persist-credentials: false
- id: art
uses: vyncint/mossaic/action@v0.7.0
with:
# The picture, seven rows by thirteen columns. `matrix` rather than
# `text` because a heart is not a letter: it uses the whole week,
# weekend included, which the 5x5 font cannot do.
matrix: heart.art
year: "2026"
# Column 35 is the week beginning Sunday 30 August 2026. Eleven
# columns from there ends on 14 November, which leaves forty-seven
# days of slack before the year does — a plan that lands on the 31st
# has no room for a week of illness.
#
# Not column 34, the week this plan was made in. Today already had
# contributions on it and the picture's top-left corner is dark, so
# starting there would have opened with a hole that nothing takes
# away. The first column the picture can have is the first one still
# entirely in the future.
#
# Keep this fixed: the plan is these inputs, and changing one
# compares against a different plan.
start-week: "35"
# No `background` and no `top`. Both place letters on rows and shade
# the field behind them; a picture names its own shade for every
# day, and mossaic-art refuses them rather than ignoring them.
timezone: Asia/Ho_Chi_Minh
# `behind` fails the job when today is a letter day and is short, so
# the failure notification you already get does the reminding.
fail-on: never
# Which mossaic release does the tracking. The default, latest,
# follows crates.io; pin a number ("0.7.0") to freeze it. Left on
# latest deliberately: this repository is where a mossaic release
# gets exercised against a real contribution graph, so following
# the newest published version is the point of it.
# version: latest
# ----------------------------------------------------------------- issue
# No secrets, nothing to sign up for. Open one issue in this repository
# and put its number here.
- name: Comment on the tracking issue
# Only when today is actually short of its target. Commenting on a
# day that needs nothing turns the tracking issue into a feed you
# stop reading, which is the one failure mode a reminder cannot
# survive.
if: steps.art.outputs.today-short != '0'
env:
GH_TOKEN: ${{ github.token }}
BODY: ${{ steps.art.outputs.markdown }}
run: gh issue comment 1 --repo "$GITHUB_REPOSITORY" --body "$BODY"
# ----------------------------------------------------------------- slack
# Settings -> Secrets and variables -> Actions -> SLACK_WEBHOOK_URL
- name: Slack
if: vars.SLACK_ENABLED == 'true'
env:
WEBHOOK: ${{ secrets.SLACK_WEBHOOK_URL }}
TEXT: ${{ steps.art.outputs.headline }}
BODY: ${{ steps.art.outputs.markdown }}
run: |
jq -n --arg t "$TEXT" --arg b "$BODY" \
'{text: $t, blocks: [{type: "section", text: {type: "mrkdwn", text: $b}}]}' \
| curl -sSf -X POST -H 'Content-type: application/json' -d @- "$WEBHOOK"
# --------------------------------------------------------------- discord
- name: Discord
if: vars.DISCORD_ENABLED == 'true'
env:
WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
BODY: ${{ steps.art.outputs.markdown }}
run: |
jq -n --arg c "$BODY" '{content: $c}' \
| curl -sSf -X POST -H 'Content-type: application/json' -d @- "$WEBHOOK"
# ----------------------------------------------------------------- email
- name: Email
if: vars.EMAIL_ENABLED == 'true'
uses: dawidd6/action-send-mail@v18
with:
server_address: smtp.gmail.com
server_port: 465
secure: true
username: ${{ secrets.MAIL_USERNAME }}
password: ${{ secrets.MAIL_PASSWORD }}
from: contribution art
to: ${{ secrets.MAIL_TO }}
subject: ${{ steps.art.outputs.headline }}
html_body: ${{ steps.art.outputs.markdown }}
# ---------------------------------------------------------- auto-commit
# Gated behind repository variable `AUTO_COMMIT_ENABLED` (e.g. 'true')
# or workflow dispatch input `auto_commit: true`.
# When today is short of its target, fills owed contributions with DCO sign-off.
- name: Checkout repository for auto-commit
if: |
steps.art.outputs.today-short != '0' &&
(inputs.auto_commit == true || vars.AUTO_COMMIT_ENABLED == 'true')
uses: actions/checkout@v4
with:
fetch-depth: 1
- name: Make owed contributions
if: |
steps.art.outputs.today-short != '0' &&
(inputs.auto_commit == true || vars.AUTO_COMMIT_ENABLED == 'true')
env:
SHORT: ${{ steps.art.outputs.today-short }}
GIT_NAME: "Vyncint Ng"
GIT_EMAIL: "vyncint@icloud.com"
run: |
echo "Hôm nay còn thiếu $SHORT commit. Đang tạo commit bù..."
git config user.name "$GIT_NAME"
git config user.email "$GIT_EMAIL"
for i in $(seq 1 "$SHORT"); do
git commit --allow-empty -s -m "mossaic: fill owed contribution $i/$SHORT [skip ci]"
done
git push origin main
echo "Đã bù xong $SHORT commit thành công!"