Skip to content

feat: enhance WriteToFileAsJSON with pretty-printing support #1334

feat: enhance WriteToFileAsJSON with pretty-printing support

feat: enhance WriteToFileAsJSON with pretty-printing support #1334

Workflow file for this run

name: vhs
on:
pull_request:
types: [labeled, opened, synchronize]
env:
TERM: "xterm-256color"
COLORTERM: "truecolor"
LANG: "en_US.UTF-8"
ATMOS_LOGS_LEVEL: "Info"
jobs:
prepare:
runs-on: ubuntu-latest
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Check for vhs label
id: labeled
env:
GH_TOKEN: ${{ github.token }}
run: |
labels=$(gh api repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels | jq -r '.[].name')
if [[ $labels =~ "vhs" ]]; then
echo "labeled=true" >> $GITHUB_OUTPUT
else
echo "labeled=false" >> $GITHUB_OUTPUT
fi
- name: Get modified .tape files
id: tapes
env:
GH_TOKEN: ${{ github.token }}
run: |
if [[ "${{ steps.labeled.outputs.labeled }}" == "true" ]]; then
echo "files=$(find . -path './build-harness' -prune -o -type f -name '*.tape' ! -name 'style.tape' ! -name 'defaults.tape' -print | cut -d/ -f2-)" >> $GITHUB_OUTPUT
else
files=$(gh pr diff --name-only ${{ github.event.pull_request.number }} | (grep '\.tape$' | grep -v '(style|defaults)\.tape$' || true) | cut -d/ -f2-)
echo "files=$files" >> $GITHUB_OUTPUT
fi
- name: Set up matrix
id: create-matrix
run: |
echo "matrix=$(echo -n ${{ steps.tapes.outputs.files }} | jq -R -s -c 'split(" ")')" >> $GITHUB_OUTPUT
outputs:
matrix: ${{ steps.create-matrix.outputs.matrix }}
labeled: ${{ steps.labeled.outputs.labeled }}
vhs:
needs: [prepare]
if: needs.prepare.outputs.matrix != '[]'
runs-on: ubuntu-latest
strategy:
matrix:
file: ${{fromJson(needs.prepare.outputs.matrix)}}
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}-${{ matrix.file }}
cancel-in-progress: true
steps:
- uses: actions/checkout@v4
- name: Install atmos
uses: jaxxstorm/[email protected]
with: # Grab the latest version
repo: cloudposse/atmos
chmod: 0755
extension-matching: disable
rename-to: atmos
- uses: charmbracelet/vhs-action@v1
with:
token: ${{ secrets.GITHUB_TOKEN }}
path: ${{ matrix.file }}
install-fonts: true
- uses: stefanzweifel/git-auto-commit-action@v4
id: auto-commit
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
commit_message: "chore: update demo gif"
commit_user_name: vhs-action 📼
commit_user_email: [email protected]
commit_author: vhs-action 📼 <[email protected]>
file_pattern: '*.gif'
- name: Add Image to Job Summary
if: steps.auto-commit.outputs.changes_detected == 'true'
run: |
echo "## Demo GIF" >> $GITHUB_STEP_SUMMARY
echo "![Demo GIF](https://github.com/${{ github.repository }}/blob/${{ steps.auto-commit.outputs.commit_hash }}/docs/demo.gif?raw=true)" >> $GITHUB_STEP_SUMMARY
- name: No changes
if: steps.auto-commit.outputs.changes_detected == 'false'
run: |
echo "No changes to demo" >> $GITHUB_STEP_SUMMARY