-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: allow updating goldens on CI (#121)
- Loading branch information
1 parent
f21d072
commit a36cf47
Showing
1 changed file
with
61 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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 |