Skip to content

Commit 3e753b5

Browse files
authored
Deno outdated custom GitHub action (#42)
1 parent 1dceb98 commit 3e753b5

File tree

10 files changed

+987
-67
lines changed

10 files changed

+987
-67
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: Deno Outdated Check
2+
description: 'Check for outdated Deno dependencies and display them in PR comments'
3+
4+
inputs:
5+
directory:
6+
description: 'Directory where to run the deno outdated check'
7+
required: true
8+
title:
9+
description: 'Message title'
10+
required: true
11+
12+
outputs:
13+
result:
14+
description: 'Result of the outdated check'
15+
value: ${{ steps.outdated.outputs.result }}
16+
17+
runs:
18+
using: "composite"
19+
steps:
20+
- uses: denoland/setup-deno@v2
21+
with:
22+
deno-version: v2.x
23+
24+
- name: Outdated packages - check
25+
id: outdated
26+
shell: bash
27+
working-directory: ${{ inputs.directory }}
28+
run: |
29+
cat deno.json
30+
bash ${{ github.workspace }}/.github/action/deno-outdated/deno-outdated.sh
31+
32+
- name: 'Outdated packages - post'
33+
uses: marocchino/sticky-pull-request-comment@v2
34+
with:
35+
recreate: true
36+
header: "outdated_${{ inputs.title }}"
37+
message: |
38+
### ${{ inputs.title }}
39+
${{ steps.outdated.outputs.result }}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#!/bin/bash
2+
3+
set -e # Exit on error
4+
set -u # Exit on undefined variable
5+
6+
TMP_FILE="outdated_$(date +%s)_$$.md"
7+
8+
# Check for outdated dependencies with recursive flag (removed quiet flag to show all outdated dependencies)
9+
OUTDATED="$(deno outdated -r)"
10+
echo "$OUTDATED"
11+
12+
# If no outdated dependencies are found, output "none", otherwise format the output
13+
if [ -z "$OUTDATED" ]; then
14+
echo "none" > "$TMP_FILE"
15+
else
16+
# Make sure the format-markdown.sh file is executable
17+
chmod +x "$(dirname "$0")/markdown/format-markdown.sh"
18+
19+
# Use the format-markdown.sh script to convert the output to markdown
20+
echo "$OUTDATED" | "$(dirname "$0")/markdown/format-markdown.sh" > "$TMP_FILE"
21+
fi
22+
23+
# If running in GitHub Actions, add the result to GitHub Actions output
24+
if [ -n "$GITHUB_OUTPUT" ]; then
25+
{
26+
echo "result<<EOF"
27+
cat "$TMP_FILE"
28+
echo "EOF"
29+
rm "$TMP_FILE"
30+
} >> "$GITHUB_OUTPUT"
31+
else
32+
echo "Outdated dependencies:"
33+
cat "$TMP_FILE"
34+
fi
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
set -e # Exit on error
4+
set -u # Exit on undefined variable
5+
6+
# Get the directory of the current script
7+
SCRIPT_DIR="$(dirname "$0")"
8+
9+
# Make sure the awk script is executable
10+
chmod +x "$SCRIPT_DIR/format-table.awk"
11+
12+
# Remove ANSI color codes from the output and convert to markdown table format using the external awk script
13+
sed -r 's/\x1B\[[0-9;]*[mK]//g' | "$SCRIPT_DIR/format-table.awk"
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/bin/bash
2+
3+
set -e # Exit on error
4+
set -u # Exit on undefined variable
5+
6+
# Create a sample ASCII table similar to the output of `deno outdated`
7+
SAMPLE_TABLE="┌───────────────────────────┬─────────┬─────────┬───────────────┐
8+
│ Package │ Current │ Update │ Latest │
9+
├───────────────────────────┼─────────┼─────────┼───────────────┤
10+
│ jsr:@supabase/supabase-js │ 2.49.8 │ 2.49.8 │ 2.49.9-next.2 │
11+
├───────────────────────────┼─────────┼─────────┼───────────────┤
12+
│ npm:lucide-react │ 0.484.0 │ 0.484.0 │ 0.511.0 │
13+
├───────────────────────────┼─────────┼─────────┼───────────────┤
14+
│ npm:react │ 19.0.0 │ 19.0.0 │ 19.1.0 │
15+
└───────────────────────────┴─────────┴─────────┴───────────────┘"
16+
17+
# Expected markdown output
18+
EXPECTED_OUTPUT="Package|Current|Update|Latest
19+
---|---|---|---
20+
jsr:@supabase/supabase-js|2.49.8|2.49.8|2.49.9-next.2
21+
npm:lucide-react|0.484.0|0.484.0|0.511.0
22+
npm:react|19.0.0|19.0.0|19.1.0"
23+
24+
# Run the format-markdown.sh script on the sample table
25+
ACTUAL_OUTPUT=$(echo "$SAMPLE_TABLE" | "$(dirname "$0")/format-markdown.sh")
26+
27+
# Compare the actual output with the expected output
28+
if [ "$ACTUAL_OUTPUT" = "$EXPECTED_OUTPUT" ]; then
29+
echo "Test passed! The format-markdown.sh script produces the expected output."
30+
else
31+
echo "Test failed! The format-markdown.sh script does not produce the expected output."
32+
echo "Expected:"
33+
echo "$EXPECTED_OUTPUT"
34+
echo "Actual:"
35+
echo "$ACTUAL_OUTPUT"
36+
exit 1
37+
fi
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/awk -f
2+
3+
BEGIN { FS = ""; OFS = "|" }
4+
5+
# Skip separator lines
6+
/^|^|^/ { next }
7+
8+
# Process table rows
9+
/^/ {
10+
# Remove leading and trailing │ and spaces
11+
gsub(/^|$/, "");
12+
13+
# Convert each cell by trimming spaces
14+
for (i=1; i<=NF; i++) {
15+
gsub(/^[[:space:]]+|[[:space:]]+$/, "", $i);
16+
}
17+
18+
# Print as markdown table row with proper column alignment
19+
# Skip the first empty column if it exists
20+
if ($1 == "") {
21+
print $2 OFS $3 OFS $4 OFS $5;
22+
} else {
23+
print $1 OFS $2 OFS $3 OFS $4;
24+
}
25+
26+
# Add header separator after the first data row
27+
if (NR == 2) {
28+
print "---|---|---|---";
29+
}
30+
}

.github/workflows/test-supabase.yml renamed to .github/workflows/pr-supabase.yml

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Check Supabase
1+
name: PR:Supabase
22

33
on:
44
pull_request:
@@ -8,21 +8,28 @@ on:
88
- synchronize
99
- ready_for_review
1010
paths:
11-
- ".github/workflows/test-supabase.yml"
11+
- ".github/workflows/pr-supabase.yml"
12+
- "deno.lock"
1213
- "supabase/**"
1314
- "!**.md"
1415
workflow_dispatch:
1516

17+
permissions:
18+
pull-requests: write
19+
1620
env:
1721
PROJECT_ID: xxx
1822
PROJECT_PUBLISHABLE_KEY: yyy
1923

2024
jobs:
2125
qa:
26+
name: 'QA'
2227
environment: test
2328
runs-on: ubuntu-latest
2429
steps:
2530
- uses: actions/checkout@v4
31+
with:
32+
ref: ${{ github.event.pull_request.head.sha }}
2633
- uses: denoland/setup-deno@v2
2734
with:
2835
deno-version: v2.x
@@ -36,4 +43,11 @@ jobs:
3643
with:
3744
name: cron_jobs.sql
3845
path: cron_jobs.sql
39-
retention-days: 1
46+
retention-days: 1
47+
48+
- name: 'Check Outdated Packages'
49+
uses: ./.github/action/deno-outdated
50+
id: outdated_supabase
51+
with:
52+
directory: ./supabase/functions
53+
title: 'Deno Outdated - Supabase'

.github/workflows/pr-web.yml

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: PR:Web
2+
3+
on:
4+
pull_request:
5+
types:
6+
- opened
7+
- reopened
8+
- synchronize
9+
- ready_for_review
10+
paths:
11+
- ".github/workflows/pr-web.yml"
12+
- "src/web/**"
13+
- "!**.md"
14+
workflow_dispatch:
15+
16+
permissions:
17+
pull-requests: write
18+
19+
jobs:
20+
qa:
21+
name: 'QA'
22+
environment: test
23+
runs-on: ubuntu-latest
24+
defaults:
25+
run:
26+
working-directory: src/web
27+
28+
steps:
29+
- uses: actions/checkout@v4
30+
with:
31+
ref: ${{ github.event.pull_request.head.sha }}
32+
- uses: denoland/setup-deno@v2
33+
with:
34+
deno-version: v2.x
35+
36+
- run: deno fmt --check
37+
- run: deno lint
38+
39+
- name: 'Build the app'
40+
run: deno task build
41+
42+
- name: 'Upload artifact'
43+
uses: actions/upload-pages-artifact@v3
44+
with:
45+
path: ./src/web/dist
46+
47+
- name: 'Check Outdated packages'
48+
uses: ./.github/action/deno-outdated
49+
with:
50+
directory: ./src/web
51+
title: 'Deno Outdated - Web'

.github/workflows/test-web.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,5 @@ dist-ssr
2727

2828
# custom
2929
supabase/functions/.env
30-
deno.lock
3130
.env
3231
cron_jobs.sql

0 commit comments

Comments
 (0)