-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
891a438
commit 3b14f0f
Showing
1 changed file
with
90 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,90 @@ | ||
name: Run PHP Script with Asciinema | ||
|
||
on: | ||
push: | ||
branches: | ||
- develop | ||
|
||
pull_request: | ||
branches: | ||
- '*' | ||
|
||
jobs: | ||
run_script: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set Up PHP Environment | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: 8.4 | ||
extensions: mbstring | ||
|
||
- name: Install Pipe Viewer (pv) | ||
run: | | ||
sudo apt install -y pv | ||
pv --version | ||
- name: Install Asciinema | ||
run: | | ||
sudo apt install -y asciinema | ||
- name: Create script.sh | ||
run: | | ||
cat > script.sh <<EOF | ||
#!/bin/bash | ||
echo "Hello, World!" | pv -qL 10 | ||
sleep 1 | ||
echo "This is a scripted session." | pv -qL 10 | ||
sleep 1 | ||
echo "Listing files:" | pv -qL 10 | ||
sleep 0.5 | ||
ls | pv -qL 10 | ||
sleep 1 | ||
echo "Goodbye!" | pv -qL 10 | ||
EOF | ||
chmod +x script.sh | ||
- name: Make script executable | ||
run: chmod +x script.sh | ||
|
||
- name: Record the script execution | ||
run: | | ||
asciinema rec --command="./script.sh" --quiet --overwrite output.cast | ||
#continue-on-error: true # To avoid action failure if no terminal output is captured. | ||
|
||
- name: Download the prebuilt `agg` binary for Ubuntu (x86_64) | ||
run: | | ||
# Download the appropriate binary for x86_64 Linux from the release page | ||
wget https://github.com/asciinema/agg/releases/download/v1.5.0/agg-x86_64-unknown-linux-gnu -O agg | ||
chmod +x agg | ||
sudo mv agg /usr/local/bin | ||
- name: Convert .cast to .gif using `agg` binary | ||
run: | | ||
# Convert the output.cast file to demo.gif | ||
agg output.cast demo.gif | ||
- name: Move demo.gif to assets folder and commit | ||
run: | | ||
# Create the assets folder if it doesn't exist | ||
mkdir -p assets | ||
# Move the demo.gif to assets folder | ||
mv demo.gif assets/demo.gif | ||
# Commit the changes and push to the repository | ||
git config --global user.name "github-actions" | ||
git config --global user.email "[email protected]" | ||
git add assets/demo.gif | ||
git commit -m "Add demo.gif to assets folder" | ||
git push origin HEAD:main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |