Skip to content

Commit

Permalink
feat: allow updating goldens on CI (#121)
Browse files Browse the repository at this point in the history
  • Loading branch information
btrautmann authored Sep 10, 2024
1 parent f21d072 commit a36cf47
Showing 1 changed file with 61 additions and 0 deletions.
61 changes: 61 additions & 0 deletions .github/workflows/update_goldens.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
name: Update Goldens
on:
workflow_dispatch:
inputs:
branch:
description: 'Branch to generate goldens from'
required: true
permissions:
contents: write

jobs:
update_goldens:
runs-on: ubuntu-latest
steps:
- name: Checkout repo
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: Validate branch input
run: |
BRANCH_PATTERN="^[a-zA-Z0-9/_.-]+$"
# Input string (branch name) to be validated
BRANCH_NAME=${{ inputs.branch}}
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
- 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@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
with:
ref: ${{ github.event.inputs.branch }}

- uses: subosito/flutter-action@v2
with:
flutter-version: '3.13.0'
channel: 'stable'
cache: true

- name: Update Goldens
run: |
flutter test --update-goldens
continue-on-error: true

- name: Commit Changes
id: commit_changes
uses: stefanzweifel/git-auto-commit-action@12f68633e45c72459cd040c868605f2471c7f63b # v5.0.0
with:
commit_message: "chore: Updating Goldens"
commit_user_name: github-actions[bot]
commit_user_email: 41898282+github-actions[bot]@users.noreply.github.com

0 comments on commit a36cf47

Please sign in to comment.