Skip to content

Commit 32a88b0

Browse files
feat(repo): add deprecate-archived-plugins workflow from BCP (#2664)
* feat(repo): add deprecate-archived-plugins workflow from BCP Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com> * Update .github/workflows/deprecate-archived-plugins.yml Co-authored-by: Hope Hadfield <hhadfiel@redhat.com> * Update scripts/ci/deprecate-archived-plugins.sh Co-authored-by: Hope Hadfield <hhadfiel@redhat.com> --------- Signed-off-by: Christoph Jerolimov <jerolimov+git@redhat.com> Co-authored-by: Hope Hadfield <hhadfiel@redhat.com>
1 parent 7ce8caa commit 32a88b0

2 files changed

Lines changed: 85 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Deprecate Archived Plugins
2+
3+
on:
4+
push:
5+
paths:
6+
- '.github/archived-plugins.json'
7+
branches:
8+
- main
9+
10+
jobs:
11+
deprecate:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Set up Node
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: 22.x
20+
registry-url: 'https://registry.npmjs.org'
21+
22+
- name: Deprecate packages
23+
run: ./scripts/ci/deprecate-archived-plugins.sh
24+
env:
25+
NODE_AUTH_TOKEN: ${{ secrets.RHDH_NPM_TOKEN }}
26+
NPM_CONFIG_REGISTRY: https://registry.npmjs.org
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
# Get script directory and archived file path
6+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
7+
ARCHIVED_FILE="$(dirname "$(dirname "$SCRIPT_DIR")")/.github/archived-plugins.json"
8+
9+
# Check if dry run (first argument)
10+
DRY_RUN=${1:-false}
11+
12+
if [[ "$DRY_RUN" == "--dry-run" ]]; then
13+
DRY_RUN=true
14+
echo "DRY RUN MODE"
15+
else
16+
DRY_RUN=false
17+
fi
18+
19+
echo "Processing archived packages..."
20+
21+
# Extract unique plugins from archived-plugins.json file
22+
# Format: package_name|workspace|plugin|reason
23+
jq -r '
24+
.archived
25+
| unique_by(.pluginName)
26+
| .[]
27+
| "\(.pluginName)|\(.workspace)|\(.plugin)|\(.reason)"
28+
' "$ARCHIVED_FILE" | while IFS='|' read -r package_name workspace plugin reason; do
29+
30+
# Check if already deprecated
31+
if npm view "$package_name" deprecated 2>/dev/null | grep -q .; then
32+
echo "Already deprecated: $package_name"
33+
continue
34+
fi
35+
# Generate deprecation message
36+
message="This package has been archived from the redhat-developer/rhdh-plugins repository"
37+
[[ -n "$plugin" ]] && message="$message (plugin: $plugin)"
38+
[[ -n "$reason" ]] && message="$message. Reason: $reason"
39+
message="$message."
40+
41+
if [[ "$DRY_RUN" == "true" ]]; then
42+
echo "Would deprecate: $package_name"
43+
echo " Message: $message"
44+
else
45+
echo "Deprecating: $package_name"
46+
47+
# Validate package exists and is accessible before deprecating
48+
if ! npm view "$package_name" version &>/dev/null; then
49+
echo "Error: Cannot view package $package_name"
50+
continue
51+
fi
52+
53+
echo "Running: npm deprecate $package_name \"$message\""
54+
npm deprecate "$package_name" "$message"
55+
echo "Done: $package_name"
56+
fi
57+
done
58+
59+
echo "Complete!"

0 commit comments

Comments
 (0)