-
Notifications
You must be signed in to change notification settings - Fork 0
89 lines (74 loc) · 3.1 KB
/
Copy pathupdate-maidr-bundle.yml
File metadata and controls
89 lines (74 loc) · 3.1 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
name: Update MAIDR Bundle
on:
schedule:
# Run daily at 9 AM UTC
- cron: '0 9 * * *'
workflow_dispatch:
# Allow manual triggering
permissions:
contents: write
jobs:
check-and-update:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup R
uses: r-lib/actions/setup-r@v2
with:
r-version: 'release'
- name: Install R dependencies
run: |
install.packages(c('jsonlite', 'rprojroot'))
shell: Rscript {0}
- name: Get latest MAIDR version from npm
id: npm-version
run: |
LATEST_VERSION=$(curl -s https://registry.npmjs.org/maidr/latest | jq -r '.version')
echo "version=$LATEST_VERSION" >> $GITHUB_OUTPUT
echo "Latest MAIDR version: $LATEST_VERSION"
- name: Get current bundled version
id: current-version
run: |
CURRENT_VERSION=$(grep 'MAIDR_VERSION <-' R/html_dependencies.R | sed 's/.*"\(.*\)".*/\1/')
echo "version=$CURRENT_VERSION" >> $GITHUB_OUTPUT
echo "Current bundled version: $CURRENT_VERSION"
- name: Check if update needed
id: check-update
run: |
if [ "${{ steps.npm-version.outputs.version }}" != "${{ steps.current-version.outputs.version }}" ]; then
echo "needs_update=true" >> $GITHUB_OUTPUT
echo "Update needed: ${{ steps.current-version.outputs.version }} -> ${{ steps.npm-version.outputs.version }}"
else
echo "needs_update=false" >> $GITHUB_OUTPUT
echo "Already up to date"
fi
- name: Download new MAIDR assets
if: steps.check-update.outputs.needs_update == 'true'
run: |
Rscript tools/update-maidr-assets.R ${{ steps.npm-version.outputs.version }}
- name: Update version in R code
if: steps.check-update.outputs.needs_update == 'true'
run: |
VERSION="${{ steps.npm-version.outputs.version }}"
OLD_VERSION="${{ steps.current-version.outputs.version }}"
# Update R/html_dependencies.R
sed -i 's/MAIDR_VERSION <- "[^"]*"/MAIDR_VERSION <- "'"$VERSION"'"/' R/html_dependencies.R
echo "Updated R/html_dependencies.R"
# Update inst/htmlwidgets/maidr.yaml
sed -i "s/version: .*/version: $VERSION/" inst/htmlwidgets/maidr.yaml
sed -i "s|src: htmlwidgets/lib/maidr-.*|src: htmlwidgets/lib/maidr-$VERSION|" inst/htmlwidgets/maidr.yaml
echo "Updated inst/htmlwidgets/maidr.yaml"
# Show changes
echo "=== Changes ==="
git diff --stat
- name: Commit and push changes
if: steps.check-update.outputs.needs_update == 'true'
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: "chore: update MAIDR bundle to v${{ steps.npm-version.outputs.version }}"
commit_user_name: "github-actions[bot]"
commit_user_email: "github-actions[bot]@users.noreply.github.com"
file_pattern: "R/html_dependencies.R inst/htmlwidgets/"