Skip to content

Commit cc1fb12

Browse files
committed
ci: new workflow to update max deposit app version in config.json
1 parent 31369d9 commit cc1fb12

File tree

2 files changed

+82
-0
lines changed

2 files changed

+82
-0
lines changed
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: Update App Version in config.json (showAppPayDepositMaxVersion)
2+
permissions:
3+
contents: write
4+
on:
5+
workflow_dispatch:
6+
inputs:
7+
max_app_version:
8+
description: 'New max app version for config.json (Major-Minor-Patch) such as: 1.7.1'
9+
default: ''
10+
required: true
11+
type: string
12+
13+
jobs:
14+
build:
15+
name: Checkout
16+
runs-on: ubuntu-latest
17+
steps:
18+
- uses: actions/checkout@v3
19+
- uses: actions/setup-node@v3
20+
with:
21+
node-version: 18.x
22+
cache: yarn
23+
cache-dependency-path: '**/yarn.lock'
24+
25+
- name: Ensure that we are running on `main`
26+
if: github.ref != 'refs/heads/main'
27+
run: |
28+
echo "❌ This workflow can only run on the main branch! You are on: ${GITHUB_REF#refs/heads/}"
29+
exit 1
30+
31+
- name: Validate supplied app version format
32+
if: ${{ github.event.inputs.max_app_version != '' }}
33+
run: |
34+
NEW_MAX_APP_VERSION="${{ github.event.inputs.max_app_version }}"
35+
36+
if [[ ! "${NEW_MAX_APP_VERSION}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then
37+
echo "NEW_MAX_APP_VERSION version must be specified in Major.Minor.Patch format"
38+
exit 1
39+
fi
40+
41+
- name: Determine new max app version
42+
id: set-max-app-version
43+
working-directory: packages/clippy/src/features/config
44+
run: |
45+
CURRENT_MAX_APP_VERSION=$(jq -r '.deposits.showAppPayDepositMaxVersion' config.json)
46+
echo "CURRENT MAX APP VERSION: ${CURRENT_MAX_APP_VERSION}"
47+
48+
if [[ "${{ github.event.inputs.max_app_version }}" != "" ]]; then
49+
NEW_MAX_APP_VERSION="${{ github.event.inputs.max_app_version }}"
50+
else
51+
echo "Max app version was not supplied"
52+
exit 1
53+
fi
54+
55+
echo "NEW MAX APP VERSION = ${NEW_MAX_APP_VERSION}"
56+
echo "new_max_app_version=${NEW_MAX_APP_VERSION}" >> "$GITHUB_OUTPUT"
57+
58+
- name: Update versions.json with new app version
59+
working-directory: packages/clippy/src/features/config
60+
run: |
61+
if [[ -z "${{ steps.set-max-app-version.outputs.new_max_app_version }}" ]]; then
62+
echo "Failed to determine new max app version"
63+
exit 1
64+
fi
65+
66+
jq --arg version "${{ steps.set-max-app-version.outputs.new_max_app_version }}" '.deposits.showAppPayDepositMaxVersion = $version' versions.json > config.temp.json
67+
mv config.temp.json config.json
68+
69+
- name: Commit new max app version to main
70+
working-directory: packages/clippy/src/features/config
71+
run: |
72+
git config user.name "github-actions"
73+
git config user.email "github-actions@github.com"
74+
git add config.json
75+
git commit -m "chore: update max app pay deposit version to ${{ steps.set-max-app-version.outputs.new_max_app_version }}"
76+
git pull --rebase origin main
77+
git push
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"deposits": {
3+
"showAppPayDepositMaxVersion": "1.7.1"
4+
}
5+
}

0 commit comments

Comments
 (0)