Skip to content

Commit d9b345e

Browse files
robbertbosanneschuth
authored andcommitted
feat(deploy): generate QR code locally with qrencode
- Replace external QR service with local qrencode generation - QR code embedded as base64 data URI (no external API calls) - Add test workflow for QR generation, input validation, payload construction - Add justfile for development tasks (auto-manages podman) - Update CONTRIBUTING.md with simplified testing instructions
1 parent 78fbc52 commit d9b345e

7 files changed

Lines changed: 67 additions & 9 deletions

File tree

.pre-commit-ci.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
ci:
2+
autoupdate_schedule: weekly
3+
# Skip hooks that are already run by CI workflow (avoid duplicates)
4+
skip: [shellcheck, actionlint, yamllint]

.pre-commit-config.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,9 @@ repos:
1919
- id: end-of-file-fixer
2020
- id: check-yaml
2121
- id: check-added-large-files
22+
23+
- repo: https://github.com/adrienverge/yamllint
24+
rev: v1.35.1
25+
hooks:
26+
- id: yamllint
27+
args: [-d, "{extends: relaxed, rules: {line-length: {max: 150}}}"]

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1717
- New inputs: `wait-for-ready`, `health-endpoint`, `wait-timeout`, `wait-interval`
1818
- Polls deployment URL until HTTP 2xx/3xx or timeout
1919
- PR comment only appears after deployment is healthy (when combined with `comment-on-pr`)
20+
- **deploy** action: QR code in PR comment
21+
- New input: `qr-code` (default: `false`)
22+
- QR code for easy mobile testing of preview deployments
23+
- Generated locally using `qrencode` (no external API calls, privacy-friendly)
2024

2125
### Changed
2226
- `.pre-commit-config.yaml`: require minimum version 4.5.0
@@ -49,6 +53,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
4953
- No longer necessary to explicitly pass `github-token: ${{ secrets.GITHUB_TOKEN }}`
5054
- Only needed when using a custom PAT for cross-repository operations
5155

56+
### Internal
57+
- Added justfile for common development tasks
58+
- Added pre-commit.ci configuration (weekly autoupdates, skip duplicates with CI)
59+
5260
### Fixed
5361
- ShellCheck warnings: properly quoted GITHUB_OUTPUT
5462
- Actionlint configuration to only lint workflow files

CONTRIBUTING.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ Thank you for your interest in contributing to ZAD Actions!
88

99
- Git
1010
- [uv](https://docs.astral.sh/uv/) (for installing pre-commit)
11+
- [just](https://github.com/casey/just) (command runner)
12+
- [ShellCheck](https://www.shellcheck.net/) (for bash script linting)
13+
- [actionlint](https://github.com/rhysd/actionlint) (for GitHub Actions validation)
1114

1215
### Setting Up Pre-commit Hooks
1316

@@ -32,10 +35,14 @@ pre-commit install
3235

3336
### Testing Locally
3437

35-
Run the pre-commit hooks to validate your changes:
38+
Use the justfile for common tasks:
3639

3740
```bash
38-
pre-commit run --all-files
41+
# List available commands
42+
just
43+
44+
# Run linting
45+
just lint
3946
```
4047

4148
### Testing in a Workflow

deploy/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Deploys a container image to ZAD Operations Manager.
2121
| `health-endpoint` | No | `/` | Endpoint to check for readiness |
2222
| `wait-timeout` | No | `300` | Maximum wait time in seconds |
2323
| `wait-interval` | No | `10` | Seconds between readiness checks |
24+
| `qr-code` | No | `false` | Include QR code for mobile access (generated locally via qrencode) |
2425

2526
## Outputs
2627

@@ -85,12 +86,16 @@ The action will create a comment like this on the PR:
8586
8687
> ## 🚀 Preview Deployment
8788
>
89+
> <img src="data:image/png;base64,..." width="100" height="100" align="right" alt="QR code">
90+
>
8891
> Your changes have been deployed to a preview environment:
8992
>
9093
> **URL:** https://web-pr85-my-project.your-domain.example.com
9194
>
9295
> This deployment will be automatically cleaned up when the PR is closed.
9396
97+
The QR code is generated locally using `qrencode` (no external API calls), making it easy to open the preview on your phone for mobile testing. To enable it, set `qr-code: true`.
98+
9499
On subsequent deployments to the same PR, the existing comment is updated instead of creating a new one.
95100

96101
### Use with GitHub Environment

deploy/action.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ inputs:
6363
description: 'Seconds between readiness checks'
6464
required: false
6565
default: '10'
66+
qr-code:
67+
description: 'Include QR code in PR comment for mobile access (generated locally via qrencode)'
68+
required: false
69+
default: 'false'
6670

6771
outputs:
6872
url:
@@ -226,6 +230,22 @@ runs:
226230
echo "::error::Deployment did not become ready within ${WAIT_TIMEOUT}s"
227231
exit 1
228232
233+
- name: Generate QR code
234+
id: qr
235+
if: inputs.qr-code == 'true' && inputs.comment-on-pr == 'true' && github.event_name == 'pull_request'
236+
shell: bash
237+
env:
238+
DEPLOYMENT_URL: ${{ steps.deploy.outputs.url }}
239+
run: |
240+
sudo apt-get install -y qrencode >/dev/null 2>&1 || true
241+
if command -v qrencode &> /dev/null; then
242+
QR_BASE64=$(qrencode -o - -t PNG -s 4 -m 1 "$DEPLOYMENT_URL" | base64 -w0)
243+
IMG="<img src='data:image/png;base64,${QR_BASE64}' width='100' height='100' align='right' alt='QR code'>"
244+
echo "html=${IMG}" >> "$GITHUB_OUTPUT"
245+
else
246+
echo "Warning: qrencode not available, skipping QR code"
247+
fi
248+
229249
- name: Comment on PR
230250
if: inputs.comment-on-pr == 'true' && github.event_name == 'pull_request'
231251
shell: bash
@@ -235,15 +255,16 @@ runs:
235255
COMMENT_HEADER: ${{ inputs.comment-header }}
236256
PR_NUMBER: ${{ github.event.pull_request.number }}
237257
GITHUB_REPOSITORY: ${{ github.repository }}
258+
QR_HTML: ${{ steps.qr.outputs.html }}
238259
run: |
239260
# Build the comment body
240-
COMMENT_BODY="${COMMENT_HEADER}
241-
242-
Your changes have been deployed to a preview environment:
243-
244-
**URL:** ${DEPLOYMENT_URL}
245-
246-
This deployment will be automatically cleaned up when the PR is closed."
261+
COMMENT_BODY="${COMMENT_HEADER}"$'\n\n'
262+
if [ -n "$QR_HTML" ]; then
263+
COMMENT_BODY+="${QR_HTML}"$'\n\n'
264+
fi
265+
COMMENT_BODY+="Your changes have been deployed to a preview environment:"$'\n\n'
266+
COMMENT_BODY+="**URL:** ${DEPLOYMENT_URL}"$'\n\n'
267+
COMMENT_BODY+="This deployment will be automatically cleaned up when the PR is closed."
247268
248269
# Check for existing comment from this action (identified by header)
249270
EXISTING_COMMENT_ID=$(gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \

justfile

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
[private]
2+
default:
3+
@just --list
4+
5+
# Run pre-commit hooks on all files
6+
lint:
7+
pre-commit run --all-files

0 commit comments

Comments
 (0)