-
Notifications
You must be signed in to change notification settings - Fork 10
75 lines (65 loc) · 2.75 KB
/
update-intersect-package.yml
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
name: "Update @intersect.mbo Package"
on:
workflow_dispatch:
inputs:
package_name:
description: "Select the @intersect.mbo package to update"
required: true
type: choice
options:
- "@intersect.mbo/govtool-outcomes-pillar-ui"
- "@intersect.mbo/intersectmbo.org-icons-set"
- "@intersect.mbo/pdf-ui"
new_version:
description: "Enter the new version (e.g., 1.1.0)"
required: true
jobs:
update_package:
runs-on: ubuntu-latest
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Node.js
uses: actions/setup-node@v4
with:
registry-url: "https://registry.npmjs.org/"
node-version-file: "./govtool/frontend/.nvmrc"
scope: "@intersect.mbo"
- name: Update package version in frontend
run: |
PACKAGE_NAME="${{ github.event.inputs.package_name }}"
NEW_VERSION="${{ github.event.inputs.new_version }}"
PACKAGE_JSON_PATH="govtool/frontend/package.json"
echo "Updating $PACKAGE_NAME to version $NEW_VERSION in $PACKAGE_JSON_PATH..."
jq --arg pkg "$PACKAGE_NAME" --arg ver "$NEW_VERSION" \
'.dependencies[$pkg] = $ver' "$PACKAGE_JSON_PATH" > package.tmp.json \
&& mv package.tmp.json "$PACKAGE_JSON_PATH"
- name: Install dependencies in frontend
run: |
cd govtool/frontend
npm install
- name: Commit and push changes
run: |
BRANCH_NAME="chore/${{ github.event.inputs.package_name }}-${{ github.event.inputs.new_version }}"
git checkout -b $BRANCH_NAME
git config user.name "github-actions[bot]"
git config user.email "github-actions[bot]@users.noreply.github.com"
git add govtool/frontend/package.json govtool/frontend/package-lock.json
git commit -m "chore: update ${{ github.event.inputs.package_name }} to ${{ github.event.inputs.new_version }}"
git push origin $BRANCH_NAME
- name: Create Pull Request
uses: peter-evans/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: "chore/${{ github.event.inputs.package_name }}-${{ github.event.inputs.new_version }}"
title: "Update ${{ github.event.inputs.package_name }} to ${{ github.event.inputs.new_version }}"
body: |
"This PR updates `${{ github.event.inputs.package_name }}` to version `${{ github.event.inputs.new_version }}`.
Workflow executed by ${{ github.actor }}."
labels: "dependencies"
sign-commits: true