Demo videos from PR builds now expire after 90 days and are posted
directly to PR threads. Uses object tagging with S3 lifecycle policies
for automatic cleanup.
## Changes
**Workflow** (`.github/workflows/tests.yml`)
- Replace `hkusu/s3-upload-action@v2` with
`ramonpaolo/action-upload-s3@main` for tagging support
- Tag uploaded objects: `expiration=90days`, `Source=github-actions`,
`Type=pr-demo-video`
- Generate unique filenames: `pr-{number}-{timestamp}.gif`
- Post PR comment with embedded video using `actions/github-script@v7`
**Documentation** (`CI_CD.md`)
- S3 lifecycle policy configuration (filters on `expiration=90days` tag)
- IAM permission requirements: `s3:PutObject`, `s3:PutObjectTagging`
## S3 Lifecycle Setup Required
```json
{
"Rules": [{
"ID": "ExpirePRDemoVideosAfter90Days",
"Status": "Enabled",
"Filter": {"Tag": {"Key": "expiration", "Value": "90days"}},
"Expiration": {"Days": 90}
}]
}
```
Apply with: `aws s3api put-bucket-lifecycle-configuration --bucket
<bucket> --lifecycle-configuration file://policy.json`
## Notes
- gh-pages `video.mp4` unaffected (served from GitHub Pages, not S3)
- Existing S3 objects without tags remain unchanged
> [!WARNING]
>
> <details>
> <summary>Firewall rules blocked me from connecting to one or more
addresses (expand for details)</summary>
>
> #### I tried to connect to the following addresses, but was blocked by
firewall rules:
>
> - `https://api.github.com/repos/ramonpaolo/action-upload-s3/tags`
> - Triggering command: `/usr/bin/curl curl -s REDACTED` (http block)
>
> If you need me to access, download, or install something from one of
these locations, you can either:
>
> - Configure [Actions setup
steps](https://gh.io/copilot/actions-setup-steps) to set up my
environment, which run before the firewall is enabled
> - Add the appropriate URLs or hosts to the custom allowlist in this
repository's [Copilot coding agent
settings](https://github.com/thomasnordquist/MQTT-Explorer/settings/copilot/coding_agent)
(admins only)
>
> </details>
<!-- START COPILOT CODING AGENT SUFFIX -->
<!-- START COPILOT ORIGINAL PROMPT -->
<details>
<summary>Original prompt</summary>
> when a demo-video is generated from a pr, add an expiration of 90 days
to the S3 file and post the video as image to the pr thread.
</details>
<!-- START COPILOT CODING AGENT TIPS -->
---
✨ Let Copilot coding agent [set things up for
you](https://github.com/thomasnordquist/MQTT-Explorer/issues/new?title=✨+Set+up+Copilot+instructions&body=Configure%20instructions%20for%20this%20repository%20as%20documented%20in%20%5BBest%20practices%20for%20Copilot%20coding%20agent%20in%20your%20repository%5D%28https://gh.io/copilot-coding-agent-tips%29%2E%0A%0A%3COnboard%20this%20repo%3E&assignees=copilot)
— coding agent works faster and does higher quality work when set up for
your repo.
---------
Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
Co-authored-by: thomasnordquist <7721625+thomasnordquist@users.noreply.github.com>
168 lines
5.3 KiB
YAML
168 lines
5.3 KiB
YAML
on:
|
|
pull_request_target: # Use pull_request_target
|
|
branches: [master, beta, release]
|
|
|
|
jobs:
|
|
test:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ghcr.io/thomasnordquist/mqtt-explorer-ui-tests:latest
|
|
volumes:
|
|
- ./:/app
|
|
options: --user root
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
- name: Install Packages
|
|
run: yarn install --frozen-lockfile
|
|
- name: Build
|
|
run: yarn build
|
|
- name: Test
|
|
run: yarn test
|
|
|
|
electron-tests:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ghcr.io/thomasnordquist/mqtt-explorer-ui-tests:latest
|
|
volumes:
|
|
- ./:/app
|
|
options: --user root
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
- name: Install Packages
|
|
run: yarn install --frozen-lockfile
|
|
- name: Build
|
|
run: yarn build
|
|
- name: Run Electron UI Tests
|
|
timeout-minutes: 10
|
|
run: ./scripts/runUiTests.sh
|
|
- name: Upload Test Screenshots
|
|
if: always()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: electron-test-screenshots
|
|
path: |
|
|
test-screenshot-*.png
|
|
retention-days: 30
|
|
|
|
demo-video:
|
|
runs-on: ubuntu-latest
|
|
container:
|
|
image: ghcr.io/thomasnordquist/mqtt-explorer-ui-tests:latest
|
|
volumes:
|
|
- ./:/app
|
|
options: --user root
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
- name: Install Packages
|
|
run: yarn install --frozen-lockfile
|
|
- name: Build
|
|
run: yarn build
|
|
- name: Generate Demo Video
|
|
run: yarn ui-test
|
|
- name: Post-processing
|
|
run: ./scripts/prepareVideo.sh
|
|
- name: Generate unique filename
|
|
id: filename
|
|
run: |
|
|
TIMESTAMP=$(date +%Y%m%d-%H%M%S)
|
|
FILENAME="pr-${{ github.event.pull_request.number }}-${TIMESTAMP}.gif"
|
|
echo "filename=${FILENAME}" >> $GITHUB_OUTPUT
|
|
- name: Upload to S3 with expiration tag
|
|
id: upload
|
|
uses: ramonpaolo/action-upload-s3@main
|
|
with:
|
|
AWS_BUCKET_NAME: ${{ vars.AWS_BUCKET }}
|
|
AWS_REGION: 'eu-central-1'
|
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
|
AWS_ACCESS_KEY_ID: ${{ vars.AWS_KEY_ID }}
|
|
local_path_upload: './ui-test.gif'
|
|
bucket_path_upload: '/'
|
|
name_to_save_on_s3: ${{ steps.filename.outputs.filename }}
|
|
tags: 'expiration=90days&Source=github-actions&Type=pr-demo-video'
|
|
- name: Generate file URL
|
|
id: fileurl
|
|
env:
|
|
AWS_BUCKET: ${{ vars.AWS_BUCKET }}
|
|
FILENAME: ${{ steps.filename.outputs.filename }}
|
|
run: |
|
|
FILE_URL="https://${AWS_BUCKET}.s3.eu-central-1.amazonaws.com/${FILENAME}"
|
|
echo "file-url=${FILE_URL}" >> $GITHUB_OUTPUT
|
|
echo "Uploaded to: ${FILE_URL}"
|
|
- name: Show URL
|
|
run: echo '${{ steps.fileurl.outputs.file-url }}'
|
|
id: artifact-upload-step
|
|
- run: echo '<picture><img src="${{ steps.fileurl.outputs.file-url }}"></picture>' \
|
|
>> $GITHUB_STEP_SUMMARY
|
|
- name: Post video to PR
|
|
uses: actions/github-script@v7
|
|
env:
|
|
VIDEO_URL: ${{ steps.fileurl.outputs.file-url }}
|
|
with:
|
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
|
script: |
|
|
const videoUrl = process.env.VIDEO_URL;
|
|
github.rest.issues.createComment({
|
|
owner: context.repo.owner,
|
|
repo: context.repo.repo,
|
|
issue_number: context.issue.number,
|
|
body: `## 🎬 Demo Video Generated\n\n\n\n_This video will expire in 90 days._`
|
|
});
|
|
|
|
test-browser:
|
|
runs-on: ubuntu-latest
|
|
services:
|
|
mosquitto:
|
|
image: eclipse-mosquitto:2
|
|
ports:
|
|
- 1883:1883
|
|
options: >-
|
|
--health-cmd "mosquitto_sub -t '$SYS/#' -C 1"
|
|
--health-interval 10s
|
|
--health-timeout 5s
|
|
--health-retries 5
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
with:
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '24'
|
|
- name: Install Dependencies
|
|
run: yarn install --frozen-lockfile
|
|
- name: Build Browser Mode
|
|
run: yarn build:server
|
|
- name: Test App
|
|
run: yarn test:app
|
|
- name: Test Backend
|
|
run: yarn test:backend
|
|
- name: Start Server in Background
|
|
run: |
|
|
yarn start:server &
|
|
echo $! > server.pid
|
|
env:
|
|
MQTT_EXPLORER_USERNAME: test
|
|
MQTT_EXPLORER_PASSWORD: test123
|
|
PORT: 3000
|
|
- name: Wait for Server
|
|
run: |
|
|
timeout 30 bash -c 'until curl -f http://localhost:3000; do sleep 1; done'
|
|
- name: Browser Smoke Test
|
|
run: |
|
|
# Test server is running
|
|
curl -f http://localhost:3000 || exit 1
|
|
echo "Browser mode server is running successfully"
|
|
- name: Stop Server
|
|
if: always()
|
|
run: |
|
|
if [ -f server.pid ]; then
|
|
kill $(cat server.pid) || true
|
|
rm server.pid
|
|
fi
|