Skip to content

Commit c0e769f

Browse files
committed
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 bb9db1c commit c0e769f

7 files changed

Lines changed: 65 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
@@ -17,3 +17,9 @@ repos:
1717
- id: end-of-file-fixer
1818
- id: check-yaml
1919
- id: check-added-large-files
20+
21+
- repo: https://github.com/adrienverge/yamllint
22+
rev: v1.35.1
23+
hooks:
24+
- id: yamllint
25+
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
@@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1212
- Automatically post/update a comment on PRs with the deployment URL
1313
- New inputs: `comment-on-pr`, `github-token`, `comment-header`
1414
- Upsert behavior: updates existing comment instead of creating duplicates
15+
- **deploy** action: QR code in PR comment
16+
- New input: `qr-code` (default: `true`)
17+
- QR code for easy mobile testing of preview deployments
18+
- Generated locally using `qrencode` (no external API calls, privacy-friendly)
1519
- **cleanup** action: PR comment update feature
1620
- Update the deploy PR comment to show cleanup status when PR is closed
1721
- New inputs: `update-pr-comment`, `comment-header`
@@ -23,6 +27,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2327
- SECURITY.md with security policy
2428
- Pre-commit hooks configuration
2529

30+
### Internal
31+
- Added justfile for common development tasks
32+
- Added pre-commit.ci configuration (weekly autoupdates, skip duplicates with CI)
33+
2634
### Fixed
2735
- ShellCheck warnings: properly quoted GITHUB_OUTPUT
2836
- Actionlint configuration to only lint workflow files

CONTRIBUTING.md

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

99
- Git
10+
- [just](https://github.com/casey/just) (command runner)
1011
- [pre-commit](https://pre-commit.com/) (for local linting)
1112
- [ShellCheck](https://www.shellcheck.net/) (for bash script linting)
1213
- [actionlint](https://github.com/rhysd/actionlint) (for GitHub Actions validation)
@@ -37,10 +38,14 @@ pre-commit run --all-files
3738

3839
### Testing Locally
3940

40-
Run the pre-commit hooks to validate your changes:
41+
Use the justfile for common tasks:
4142

4243
```bash
43-
pre-commit run --all-files
44+
# List available commands
45+
just
46+
47+
# Run linting
48+
just lint
4449
```
4550

4651
### Testing in a Workflow

deploy/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Deploys a container image to ZAD Operations Manager.
1717
| `comment-on-pr` | No | `false` | Post/update a comment on the PR with the deployment URL |
1818
| `github-token` | No | `''` | GitHub token for PR commenting (needs `pull-requests: write`) |
1919
| `comment-header` | No | `## 🚀 Preview Deployment` | Custom header for the PR comment |
20+
| `qr-code` | No | `true` | Include QR code for mobile access (generated locally via qrencode) |
2021

2122
## Outputs
2223

@@ -86,12 +87,16 @@ The action will create a comment like this on the PR:
8687
8788
> ## 🚀 Preview Deployment
8889
>
90+
> <img src="data:image/png;base64,..." width="100" height="100" align="right" alt="QR code">
91+
>
8992
> Your changes have been deployed to a preview environment:
9093
>
9194
> **URL:** https://web-pr123-my-project.rig.prd1.gn2.quattro.rijksapps.nl
9295
>
9396
> This deployment will be automatically cleaned up when the PR is closed.
9497
98+
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 disable it, set `qr-code: false`.
99+
95100
On subsequent deployments to the same PR, the existing comment is updated instead of creating a new one.
96101

97102
### Use with GitHub Environment

deploy/action.yml

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ inputs:
4747
description: 'Custom header for the PR comment (default: "## 🚀 Preview Deployment")'
4848
required: false
4949
default: '## 🚀 Preview Deployment'
50+
qr-code:
51+
description: 'Include QR code in PR comment for mobile access (generated locally via qrencode)'
52+
required: false
53+
default: 'true'
5054

5155
outputs:
5256
url:
@@ -181,6 +185,22 @@ runs:
181185
exit 1
182186
fi
183187
188+
- name: Generate QR code
189+
id: qr
190+
if: inputs.qr-code == 'true' && inputs.comment-on-pr == 'true' && github.event_name == 'pull_request'
191+
shell: bash
192+
env:
193+
DEPLOYMENT_URL: ${{ steps.deploy.outputs.url }}
194+
run: |
195+
sudo apt-get install -y qrencode >/dev/null 2>&1 || true
196+
if command -v qrencode &> /dev/null; then
197+
QR_BASE64=$(qrencode -o - -t PNG -s 4 -m 1 "$DEPLOYMENT_URL" | base64 -w0)
198+
IMG="<img src='data:image/png;base64,${QR_BASE64}' width='100' height='100' align='right' alt='QR code'>"
199+
echo "html=${IMG}" >> "$GITHUB_OUTPUT"
200+
else
201+
echo "Warning: qrencode not available, skipping QR code"
202+
fi
203+
184204
- name: Comment on PR
185205
if: inputs.comment-on-pr == 'true' && inputs.github-token != '' && github.event_name == 'pull_request'
186206
shell: bash
@@ -190,15 +210,16 @@ runs:
190210
COMMENT_HEADER: ${{ inputs.comment-header }}
191211
PR_NUMBER: ${{ github.event.pull_request.number }}
192212
GITHUB_REPOSITORY: ${{ github.repository }}
213+
QR_HTML: ${{ steps.qr.outputs.html }}
193214
run: |
194215
# Build the comment body
195-
COMMENT_BODY="${COMMENT_HEADER}
196-
197-
Your changes have been deployed to a preview environment:
198-
199-
**URL:** ${DEPLOYMENT_URL}
200-
201-
This deployment will be automatically cleaned up when the PR is closed."
216+
COMMENT_BODY="${COMMENT_HEADER}"$'\n\n'
217+
if [ -n "$QR_HTML" ]; then
218+
COMMENT_BODY+="${QR_HTML}"$'\n\n'
219+
fi
220+
COMMENT_BODY+="Your changes have been deployed to a preview environment:"$'\n\n'
221+
COMMENT_BODY+="**URL:** ${DEPLOYMENT_URL}"$'\n\n'
222+
COMMENT_BODY+="This deployment will be automatically cleaned up when the PR is closed."
202223
203224
# Check for existing comment from this action (identified by header)
204225
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)