Add demo workflow #38
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
name: Demo | |
on: | |
workflow_dispatch: | |
pull_request: | |
types: [labeled, opened, synchronize] | |
paths: | |
- ".github/workflows/demo.yml" | |
env: | |
TERM: "xterm-256color" | |
COLORTERM: "truecolor" | |
LANG: "en_US.UTF-8" | |
ATMOS_LOGS_LEVEL: "Info" | |
TERRAFORM_VERSION: "1.9.7" | |
jobs: | |
prepare: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get Atmos version | |
id: get-version | |
run: | | |
VERSION=$(curl -s https://api.github.com/repos/cloudposse/atmos/releases/latest | jq -r .tag_name) | |
echo "version=$VERSION" >> $GITHUB_OUTPUT | |
- name: List all .tape files | |
id: list-tapes | |
run: | | |
files=$(git ls-files | grep 'demo.tape$' || true) | |
if [ -z "$files" ]; then | |
echo "matrix=[]" >> $GITHUB_OUTPUT | |
else | |
matrix=$(echo "$files" | jq -R -s -c 'split("\n") | map(select(length > 0))') | |
echo "matrix=$matrix" >> $GITHUB_OUTPUT | |
fi | |
cat $GITHUB_OUTPUT | |
outputs: | |
matrix: ${{ steps.list-tapes.outputs.matrix }} | |
version: ${{ steps.get-version.outputs.version }} | |
screengrabs: | |
needs: [prepare] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y aha util-linux make jq bat | |
sudo ln -s /usr/bin/batcat /usr/bin/bat | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Install Atmos | |
uses: jaxxstorm/action-install-gh-release@v1.11.0 | |
with: | |
repo: cloudposse/atmos | |
tag: ${{ needs.prepare.outputs.version }} | |
chmod: 0755 | |
extension-matching: disable | |
rename-to: atmos | |
- uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: ${{ env.TERRAFORM_VERSION }} | |
terraform_wrapper: false | |
- name: Run make build-all install | |
run: | | |
make -C demo/screengrabs build-all install | |
git add -A | |
git status | |
- name: Create or update PR | |
uses: peter-evans/create-pull-request@v7 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: "chore/update-build-screengrabs-for-${{ needs.prepare.outputs.version }}" | |
title: "Update screengrabs for ${{ needs.prepare.outputs.version }}" | |
delete-branch: true | |
sign-commits: true | |
commit-message: | | |
chore: update screengrabs for ${{ needs.prepare.outputs.version }} | |
body: | | |
This PR updates the screengrabs for Atmos version ${{ needs.prepare.outputs.version }}. | |
base: main | |
labels: "no-release" | |
vhs: | |
needs: [prepare] | |
runs-on: ubuntu-latest | |
timeout-minutes: 120 | |
strategy: | |
matrix: | |
file: ${{ fromJson(needs.prepare.outputs.matrix) }} | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }}-${{ matrix.file }} | |
cancel-in-progress: true | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set Swap Space | |
uses: pierotofy/set-swap-space@0404882bc4666c0ff2f6fd8b3d32af69a730183c | |
with: | |
swap-size-gb: 15 | |
- name: Install Atmos | |
uses: jaxxstorm/action-install-gh-release@v1.11.0 | |
with: | |
repo: cloudposse/atmos | |
tag: ${{ needs.prepare.outputs.version }} | |
chmod: 0755 | |
extension-matching: disable | |
rename-to: atmos | |
- uses: hashicorp/setup-terraform@v3 | |
with: | |
terraform_version: ${{ env.TERRAFORM_VERSION }} | |
terraform_wrapper: false | |
- name: Test Atmos | |
run: | | |
which atmos | |
atmos version | |
atmos --help | |
- name: Prepare variables | |
id: vars | |
run: | | |
VERSION="${{ needs.prepare.outputs.version }}" | |
JOB_NAME=$(basename "${{ matrix.file }}" | sed 's/.tape$//') | |
echo "version=${VERSION}" >> $GITHUB_OUTPUT | |
echo "job_name=${JOB_NAME}" >> $GITHUB_OUTPUT | |
echo "branch_name=chore/update-${JOB_NAME}-for-${VERSION}" >> $GITHUB_OUTPUT | |
- name: Setup VHS | |
uses: charmbracelet/vhs-action@v2 | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
install-fonts: true | |
- name: Record screencast | |
run: | | |
vhs ${{ matrix.file }} | |
- name: Create or update PR | |
uses: peter-evans/create-pull-request@v7 | |
id: auto-commit | |
with: | |
token: ${{ secrets.GITHUB_TOKEN }} | |
branch: ${{ steps.vars.outputs.branch_name }} | |
sign-commits: true | |
commit-message: | | |
chore: update ${{ steps.vars.outputs.job_name }} for ${{ steps.vars.outputs.version }} | |
title: Update ${{ steps.vars.outputs.job_name }} for ${{ steps.vars.outputs.version }} | |
body: | | |
This PR updates the demo gif for ${{ steps.vars.outputs.job_name }} with Atmos version ${{ steps.vars.outputs.version }}. | |
base: main | |
labels: no-release | |
- name: Add Image to Job Summary | |
if: steps.auto-commit.outputs.pull-request-operation == 'created' || steps.auto-commit.outputs.pull-request-operation == 'updated' | |
run: | | |
echo "## Demo GIF" >> $GITHUB_STEP_SUMMARY | |
echo "![Demo GIF](https://github.com/${{ github.repository }}/blob/${{ steps.auto-commit.outputs.pull-request-head-sha }}/docs/demo.gif?raw=true)" >> $GITHUB_STEP_SUMMARY | |
- name: No changes | |
if: steps.auto-commit.outputs.pull-request-operation == 'none' || steps.auto-commit.outputs.pull-request-operation == 'closed' | |
run: | | |
echo "No changes to demo" >> $GITHUB_STEP_SUMMARY |