Skip to content

Update Goldens

Update Goldens #4

name: Update Goldens
# ignore: RiskyTriggers
on:
workflow_dispatch:
inputs:
branch:
description: "Branch to generate goldens on"
required: true
flutter_version:
description: "Flutter version to use"
required: true
permissions:
contents: write
jobs:
update_goldens:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Validate branch input
run: |
BRANCH_PATTERN="^[a-zA-Z0-9/_.-]+$"
echo "Checking branch name: $BRANCH_NAME"
# Validate branch name against the regex pattern
if [[ $BRANCH_NAME =~ $BRANCH_PATTERN ]]; then
echo "Branch name is valid."
exit 0
else
echo "Branch name is invalid."
exit 1
fi
env:
BRANCH_NAME: ${{ inputs.branch }}
- name: Validate Flutter version input
run: |
VERSION_PATTERN="^[0-9]+\.[0-9]+\.[0-9]+$"
echo "Checking version input: $VERSION"
# Validate branch name against the regex pattern
if [[ $VERSION =~ $VERSION_PATTERN ]]; then
echo "Version input is valid."
exit 0
else
echo "Version input is invalid."
exit 1
fi
env:
VERSION: ${{ inputs.flutter_version }}
- name: Ensure branch is not main
if: ${{ github.event.inputs.branch == 'main' || github.event.inputs.branch == 'origin/main'}}
run: exit 1
- name: Checkout branch
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
with:
# Branch validated above
# ignore: UnsafeCheckout
ref: ${{ github.event.inputs.branch }}
- uses: subosito/flutter-action@e938fdf56512cc96ef2f93601a5a40bde3801046 # v2.19.0
with:
flutter-version: ${{ github.event.inputs.flutter_version }}
channel: any
cache: true
- name: Disable animations
run: flutter config --no-cli-animations
- name: Update Goldens
run: |
flutter test --update-goldens
continue-on-error: true
- name: Commit Changes
id: commit_changes
env:
BRANCH_NAME: ${{ github.event.inputs.branch }}
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add .
git diff-index --quiet HEAD || git commit -m "chore: Updating Goldens"
git push origin HEAD:"$BRANCH_NAME"