Update App Version in config.json (showAppPayDepositMaxVersion) #3
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Update App Version in config.json (showAppPayDepositMaxVersion) | |
permissions: | |
contents: write | |
on: | |
workflow_dispatch: | |
inputs: | |
max_app_version: | |
description: 'New max app version for config.json (Major-Minor-Patch) such as: 1.7.1' | |
default: '' | |
required: true | |
type: string | |
jobs: | |
build: | |
name: Checkout | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: 18.x | |
cache: yarn | |
cache-dependency-path: '**/yarn.lock' | |
- name: Ensure that we are running on `main` | |
if: github.ref != 'refs/heads/main' | |
run: | | |
echo "❌ This workflow can only run on the main branch! You are on: ${GITHUB_REF#refs/heads/}" | |
exit 1 | |
- name: Validate supplied app version format | |
run: | | |
NEW_MAX_APP_VERSION="${{ github.event.inputs.max_app_version }}" | |
if [[ ! "${NEW_MAX_APP_VERSION}" =~ ^([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | |
echo "NEW_MAX_APP_VERSION version must be specified in Major.Minor.Patch format" | |
exit 1 | |
fi | |
- name: Determine new max app version | |
id: set-max-app-version | |
working-directory: packages/clippy/src/features/config | |
run: | | |
NEW_MAX_APP_VERSION="${{ github.event.inputs.max_app_version }}" | |
echo "NEW MAX APP VERSION = ${NEW_MAX_APP_VERSION}" | |
echo "new_max_app_version=${NEW_MAX_APP_VERSION}" >> "$GITHUB_OUTPUT" | |
- name: Ensure that the new max version is different from the current version | |
working-directory: packages/clippy/src/features/config | |
run: | | |
CURRENT_MAX_APP_VERSION=$(jq -r '.deposits.showAppPayDepositMaxVersion' config.json) | |
NEW_MAX_APP_VERSION="${{ github.event.inputs.max_app_version }}" | |
if [[ "$NEW_MAX_APP_VERSION" == "$CURRENT_MAX_APP_VERSION" ]]; then | |
echo " Version hasn't changed — not committing." | |
exit 0 | |
fi | |
- name: Update config.json with new app version | |
working-directory: packages/clippy/src/features/config | |
run: | | |
jq --arg version "${{ steps.set-max-app-version.outputs.new_max_app_version }}" '.deposits.showAppPayDepositMaxVersion = $version' config.json > config.temp.json | |
mv config.temp.json config.json | |
- name: Commit new max app version to main | |
working-directory: packages/clippy/src/features/config | |
run: | | |
git config user.name "github-actions" | |
git config user.email "github-actions@github.com" | |
git add config.json | |
git commit -m "chore: update max app pay deposit version to ${{ steps.set-max-app-version.outputs.new_max_app_version }}" | |
git pull --rebase origin main | |
git push |