File tree Expand file tree Collapse file tree 3 files changed +20
-30
lines changed
Expand file tree Collapse file tree 3 files changed +20
-30
lines changed Original file line number Diff line number Diff line change @@ -34,38 +34,21 @@ jobs:
3434 - name : List Installed Dependencies
3535 run : composer show -D
3636
37- - name : Get latest GitHub Statistics
37+ - name : Get latest GitHub statistics
3838 id : stats
3939 env :
4040 GH_TOKEN : ${{ secrets.GITHUB_TOKEN }}
4141 run : |
4242 set -e
43-
44- # Get stargazers
4543 STARS=$(curl -s -H "Authorization: Bearer $GH_TOKEN" https://api.github.com/repos/tempestphp/tempest-framework | jq '.stargazers_count // empty')
46- STARS_K=""
47- if [ -n "$STARS" ]; then
48- if [ "$STARS" -gt 999 ]; then
49- STARS_K=$(awk "BEGIN { printf \"%.1fK\", $STARS/1000 }")
50- else
51- STARS_K=$STARS
52- fi
53- fi
54-
55- # Get latest release tag
5644 TAG=$(curl -s -H "Authorization: Bearer $GH_TOKEN" https://api.github.com/repos/tempestphp/tempest-framework/releases/latest | jq -r '.tag_name // empty')
57-
58- echo "Stars: $STARS_K"
59- echo "Latest Version: $TAG"
60-
61- # Push these values to the output
62- echo "stars=$STARS_K" >> "$GITHUB_OUTPUT"
45+ echo "Stars: $STARS"
46+ echo "Latest version: $TAG"
47+ echo "stars=$STARS" >> "$GITHUB_OUTPUT"
6348 echo "latest_tag=$TAG" >> "$GITHUB_OUTPUT"
6449
6550 - name : Deploy
6651 run : php ./tempest deploy
6752 env :
6853 TEMPEST_BUILD_STARGAZERS : ${{ steps.stats.outputs.stars }}
6954 TEMPEST_BUILD_LATEST_RELEASE : ${{ steps.stats.outputs.latest_tag }}
70-
71-
Original file line number Diff line number Diff line change @@ -30,9 +30,8 @@ public function __invoke(): ?string
3030 ->body ;
3131
3232 return json_decode ($ body )->tag_name ?? $ defaultRelease ;
33- } catch (Throwable $ e ) {
34- ll ($ e );
35- return Kernel::VERSION ;
33+ } catch (Throwable ) {
34+ return $ defaultRelease ;
3635 }
3736 }
3837}
Original file line number Diff line number Diff line change 22
33namespace App \GitHub ;
44
5+ use PDO ;
56use Tempest \HttpClient \HttpClient ;
67use Throwable ;
78
@@ -15,6 +16,17 @@ public function __construct(
1516 }
1617
1718 public function __invoke (): ?string
19+ {
20+ if ($ stargazers = $ this ->getStargazersCount ()) {
21+ return $ stargazers > 999
22+ ? (round ($ stargazers / 1000 , 1 ) . 'K ' )
23+ : $ stargazers ;
24+ }
25+
26+ return null ;
27+ }
28+
29+ private function getStargazersCount (): ?int
1830 {
1931 if ($ stargazers = env ('TEMPEST_BUILD_STARGAZERS ' )) {
2032 return $ stargazers ;
@@ -24,13 +36,9 @@ public function __invoke(): ?string
2436 $ body = $ this ->httpClient
2537 ->get (uri: 'https://api.github.com/repos/tempestphp/tempest-framework ' )
2638 ->body ;
27- $ stargazers = json_decode ($ body )->stargazers_count ?? null ;
2839
29- return $ stargazers > 999
30- ? (round ($ stargazers / 1000 , 1 ) . 'K ' )
31- : $ stargazers ;
32- } catch (Throwable $ e ) {
33- ll ($ e );
40+ return $ stargazers = json_decode ($ body )->stargazers_count ?? null ;
41+ } catch (\Throwable ) {
3442 return null ;
3543 }
3644 }
You can’t perform that action at this time.
0 commit comments