Skip to content

Pin dependencies

Pin dependencies #2877

Workflow file for this run

# https://zenn.dev/aiji42/articles/6656072a954a9b
name: Visual Regression Testing Update By PR Comment
on:
issue_comment:
types: [created, edited]
jobs:
lost-pixel:
# PR中のコメントに /update-vrt と入力するとアクションが発動する
if: contains(github.event.comment.html_url, '/pull/') && startsWith(github.event.comment.body, '/update-vrt')
name: 📸 Lost Pixel Baseline Update By PR Comment
runs-on: ubuntu-latest
env:
TURBO_TOKEN: ${{ secrets.TURBO_TOKEN }}
TURBO_TEAM: ${{ vars.TURBO_TEAM }}
permissions:
contents: write
pull-requests: write
strategy:
matrix:
config:
- { package: "apps/blog", name: "Lost Pixel for blog page", command: "bun run start" }
defaults:
run:
working-directory: ${{ matrix.config.package }}
steps:
- name: Get branch name
uses: xt0rted/pull-request-comment-branch@v2
id: comment-branch
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Commit
uses: actions/checkout@v3
with:
ref: ${{ steps.comment-branch.outputs.head_ref }}
fetch-depth: 0 # 全ブランチの履歴を取得
- name: Create .env file
run: |
touch .env
echo "ZENN_URL=${{ secrets.ZENN_URL }}" >> .env
echo "ZENN_BASE_URL=${{ secrets.ZENN_BASE_URL }}" >> .env
- name: Setup Git User
run: |
git config --global user.name 'GitHub Actions'
git config --global user.email '[email protected]'
- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest
- name: Install dependencies
run: cd ../../ && bun install
- name: Build UI
working-directory: ./packages/ui
run: bun run build
- name: Build App
run: cd ../../ && bun run build
- name: Start App
run: cd . && ${{ matrix.config.command }} &
- name: Lost Pixel Update
id: lostpixel
uses: lost-pixel/[email protected]
env:
LOST_PIXEL_MODE: update
LOST_PIXEL_DISABLE_TELEMETRY: 1
LOST_PIXEL_CONFIG_DIR: ${{ matrix.config.package }}
- name: Give Permission to untracked files
if: ${{ failure() && steps.lostpixel.conclusion == 'failure' }}
run: sudo chown -R $USER:$USER .
- name: Check existing Lost Pixel PR
id: check-pr
run: |
existing_pr=$(gh pr list --base ${{ steps.comment-branch.outputs.head_ref }} --label update-lost-pixel --json number,head.ref --jq '.[] | select(.head.ref | startswith("lost-pixel-update/")) | .number')
echo "::set-output name=pr_number::$existing_pr"
- name: Create new branch
if: ${{ failure() && steps.lostpixel.conclusion == 'failure' && steps.check-pr.outputs.pr_number == '' }}
run: |
git checkout -b lost-pixel-update/${{ steps.comment-branch.outputs.head_ref }}
- name: Checkout existing PR branch
if: ${{ failure() && steps.lostpixel.conclusion == 'failure' && steps.check-pr.outputs.pr_number != '' }}
run: |
git checkout lost-pixel-update/${{ steps.comment-branch.outputs.head_ref }}
- name: Add untracked files
if: ${{ failure() && steps.lostpixel.conclusion == 'failure' }}
run: |
git add .
- name: Create commit
if: ${{ failure() && steps.lostpixel.conclusion == 'failure' }}
run: |
git commit -m "Update VRT baseline images" || echo "No changes to commit"
- name: Push changes
if: ${{ failure() && steps.lostpixel.conclusion == 'failure' }}
run: |
git push origin HEAD:lost-pixel-update/${{ steps.comment-branch.outputs.head_ref }} --force
- name: Create Pull Request
if: ${{ failure() && steps.lostpixel.conclusion == 'failure' && steps.check-pr.outputs.pr_number == '' }}
run: |
gh pr create --base ${{ steps.comment-branch.outputs.head_ref }} \
--head lost-pixel-update/${{ steps.comment-branch.outputs.head_ref }} \
--label update-lost-pixel \
--title 'Lost Pixel Update - ${{ steps.comment-branch.outputs.head_ref }}' \
--body 'Automated baseline update created by Lost Pixel'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}