@@ -12,7 +12,6 @@ public partial class Form1 : Form
1212 {
1313 private readonly NotifyIcon trayIcon ;
1414 private readonly System . Windows . Forms . Timer checkTimer ;
15- private readonly AppConfig config ;
1615 private string lastSha = string . Empty ;
1716
1817 protected override void OnLoad ( EventArgs e )
@@ -22,9 +21,8 @@ protected override void OnLoad(EventArgs e)
2221 this . ShowInTaskbar = false ;
2322 }
2423
25- public Form1 ( AppConfig loadedConfig )
24+ public Form1 ( )
2625 {
27- config = loadedConfig ;
2826 InitializeComponent ( ) ;
2927
3028 trayIcon = new NotifyIcon
@@ -48,9 +46,9 @@ public Form1(AppConfig loadedConfig)
4846 private async Task InitializeMonitorAsync ( )
4947 {
5048 using var client = new HttpClient ( ) ;
51- client . DefaultRequestHeaders . Add ( "User-Agent" , "GitHubDeployMonitor " ) ;
52- if ( config . UsePrivateKey && ! string . IsNullOrWhiteSpace ( config . ApiKey ) )
53- client . DefaultRequestHeaders . Add ( "Authorization" , $ "Bearer { config . ApiKey } ") ;
49+ client . DefaultRequestHeaders . Add ( "User-Agent" , "GitHubPagesDeployMonitor " ) ;
50+ if ( Properties . Settings . Default . UsePrivateKey && ! string . IsNullOrWhiteSpace ( Properties . Settings . Default . ApiKey ) )
51+ client . DefaultRequestHeaders . Add ( "Authorization" , $ "Bearer { Properties . Settings . Default . ApiKey } ") ;
5452
5553 try
5654 {
@@ -79,18 +77,18 @@ private async Task InitializeMonitorAsync()
7977 private void OpenSettings ( object ? sender , EventArgs e )
8078 {
8179 checkTimer . Stop ( ) ;
82- using var form = new SettingsForm ( config ) ;
80+ using var form = new SettingsForm ( ) ;
8381 form . ShowDialog ( ) ;
8482 InitializeMonitorAsync ( ) . ConfigureAwait ( false ) ;
8583 }
8684
8785 private async Task CheckGitHub ( )
8886 {
8987 using var client = new HttpClient ( ) ;
90- client . DefaultRequestHeaders . Add ( "User-Agent" , "GitHubDeployMonitor " ) ;
88+ client . DefaultRequestHeaders . Add ( "User-Agent" , "GitHubPagesDeployMonitor " ) ;
9189
92- if ( config . UsePrivateKey && ! string . IsNullOrWhiteSpace ( config . ApiKey ) )
93- client . DefaultRequestHeaders . Add ( "Authorization" , $ "Bearer { config . ApiKey } ") ;
90+ if ( Properties . Settings . Default . UsePrivateKey && ! string . IsNullOrWhiteSpace ( Properties . Settings . Default . ApiKey ) )
91+ client . DefaultRequestHeaders . Add ( "Authorization" , $ "Bearer { Properties . Settings . Default . ApiKey } ") ;
9492
9593 try
9694 {
@@ -110,9 +108,26 @@ private async Task CheckGitHub()
110108 var content = await response . Content . ReadAsStringAsync ( ) ;
111109 var doc = JsonDocument . Parse ( content ) ;
112110 var sha = doc . RootElement . GetProperty ( "sha" ) . GetString ( ) ;
113-
111+ var author = doc . RootElement . GetProperty ( "commit" )
112+ . GetProperty ( "author" )
113+ . GetProperty ( "name" )
114+ . GetString ( ) ;
115+ if ( author != null )
116+ {
117+ foreach ( var item in Properties . Settings . Default . NamesToIgnore )
118+ {
119+ if ( item != null )
120+ {
121+ if ( author . Contains ( item ) )
122+ {
123+ return ;
124+ }
125+ }
126+ }
127+ }
114128 if ( ! string . IsNullOrEmpty ( sha ) && sha != lastSha )
115129 {
130+ Console . WriteLine ( $ "New commit detected with sha f{ sha } ") ;
116131 lastSha = sha ;
117132 trayIcon . ShowBalloonTip ( 1000 , "📦 New Push" , "New push detected." , ToolTipIcon . Info ) ;
118133 _ = MonitorChecksAsync ( sha ) ;
@@ -134,25 +149,33 @@ private void ShowRepoError()
134149 private async Task MonitorChecksAsync ( string sha )
135150 {
136151 using var client = new HttpClient ( ) ;
137- client . DefaultRequestHeaders . Add ( "User-Agent" , "GitHubDeployMonitor " ) ;
138- if ( config . UsePrivateKey && ! string . IsNullOrWhiteSpace ( config . ApiKey ) )
139- client . DefaultRequestHeaders . Add ( "Authorization" , $ "Bearer { config . ApiKey } ") ;
152+ client . DefaultRequestHeaders . Add ( "User-Agent" , "GitHubPagesDeployMonitor " ) ;
153+ if ( Properties . Settings . Default . UsePrivateKey && ! string . IsNullOrWhiteSpace ( Properties . Settings . Default . ApiKey ) )
154+ client . DefaultRequestHeaders . Add ( "Authorization" , $ "Bearer { Properties . Settings . Default . ApiKey } ") ;
140155
141156 while ( true )
142157 {
143- await Task . Delay ( 5000 ) ;
158+ await Task . Delay ( Properties . Settings . Default . CheckInterval ) ;
144159 try
145160 {
146161 var url = $ "https://api.github.com/repos/{ Properties . Settings . Default . RepoDirectory } /commits/{ sha } /check-runs";
147162 var resp = await client . GetStringAsync ( url ) ;
148163 var doc = JsonDocument . Parse ( resp ) ;
149164 var checks = doc . RootElement . GetProperty ( "check_runs" ) ;
150- int total = checks . GetArrayLength ( ) ;
151- int completed = checks . EnumerateArray ( ) . Count ( c => c . GetProperty ( "status" ) . GetString ( ) == "completed" ) ;
152- if ( completed == total && total > 0 )
165+ foreach ( var check in checks . EnumerateArray ( ) )
153166 {
154- trayIcon . ShowBalloonTip ( 1000 , "✅ Deploy Complete" , "Your GitHub Page has been updated." , ToolTipIcon . Info ) ;
155- break ;
167+ if ( check . GetProperty ( "name" ) . GetString ( ) == "deploy" )
168+ {
169+ var status = check . GetProperty ( "status" ) . GetString ( ) ;
170+ var conclusion = check . GetProperty ( "conclusion" ) . GetString ( ) ;
171+
172+ if ( status == "completed" && conclusion == "success" )
173+ {
174+ Console . WriteLine ( "Checks completed" ) ;
175+ trayIcon . ShowBalloonTip ( 1000 , "✅ Deploy Complete" , "Your GitHub Page has been updated." , ToolTipIcon . Info ) ;
176+ return ;
177+ }
178+ }
156179 }
157180 }
158181 catch
0 commit comments