Skip to content

Commit e749b11

Browse files
committed
feat(#2968): add workflow to update any of the @intersect.mbo package
1 parent 6f80494 commit e749b11

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: "Update @intersect.mbo Package"
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
package_name:
7+
description: "Select the @intersect.mbo package to update"
8+
required: true
9+
type: choice
10+
options:
11+
- "@intersect.mbo/govtool-outcomes-pillar-ui"
12+
- "@intersect.mbo/intersectmbo.org-icons-set"
13+
- "@intersect.mbo/pdf-ui"
14+
new_version:
15+
description: "Enter the new version (e.g., 1.1.0)"
16+
required: true
17+
18+
jobs:
19+
update_package:
20+
runs-on: ubuntu-latest
21+
permissions:
22+
contents: write
23+
pull-requests: write
24+
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
token: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Setup Node.js
32+
uses: actions/setup-node@v4
33+
with:
34+
node-version-file: "./govtool/frontend/.nvmrc"
35+
cache: "npm"
36+
37+
- name: Update package version in frontend
38+
run: |
39+
PACKAGE_NAME="${{ github.event.inputs.package_name }}"
40+
NEW_VERSION="${{ github.event.inputs.new_version }}"
41+
PACKAGE_JSON_PATH="govtool/frontend/package.json"
42+
43+
echo "Updating $PACKAGE_NAME to version $NEW_VERSION in $PACKAGE_JSON_PATH..."
44+
45+
jq --arg pkg "$PACKAGE_NAME" --arg ver "$NEW_VERSION" \
46+
'.dependencies[$pkg] = $ver' "$PACKAGE_JSON_PATH" > package.tmp.json \
47+
&& mv package.tmp.json "$PACKAGE_JSON_PATH"
48+
49+
- name: Install dependencies in frontend
50+
run: |
51+
cd govtool/govtool/frontend
52+
npm install
53+
54+
- name: Commit and push changes
55+
run: |
56+
BRANCH_NAME="update-${{ github.event.inputs.package_name }}-${{ github.event.inputs.new_version }}"
57+
git checkout -b $BRANCH_NAME
58+
git config user.name "github-actions[bot]"
59+
git config user.email "github-actions[bot]@users.noreply.github.com"
60+
git add govtool/govtool/frontend/package.json govtool/govtool/frontend/package-lock.json
61+
git commit -m "chore: update ${{ github.event.inputs.package_name }} to ${{ github.event.inputs.new_version }}"
62+
git push origin $BRANCH_NAME
63+
64+
- name: Create Pull Request
65+
uses: peter-evans/create-pull-request@v7
66+
with:
67+
token: ${{ secrets.GITHUB_TOKEN }}
68+
branch: ${{ github.event.inputs.package_name }}-${{ github.event.inputs.new_version }}
69+
title: "Update ${{ github.event.inputs.package_name }} to ${{ github.event.inputs.new_version }}"
70+
body: "This PR updates ${{ github.event.inputs.package_name }} to version ${{ github.event.inputs.new_version }}."
71+
labels: "dependencies"
72+
sign-commits: true

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ changes.
1515
- Add metadata url and hash to drep details [Issue 2911](https://github.com/IntersectMBO/govtool/issues/2911)
1616
- Add CC votes percentages, not voted and Ratification threshold
1717
- Add support for submitting all 7 governance action types [Issue 2258](https://github.com/IntersectMBO/govtool/issues/2258)
18+
- Add workflow to automatically update any of the @intersect.mbo package [Issue 2968](https://github.com/IntersectMBO/govtool/issues/2968)
1819

1920
### Fixed
2021

0 commit comments

Comments
 (0)