Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .pre-commit-ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ci:
autoupdate_schedule: weekly
# Skip hooks that are already run by CI workflow (avoid duplicates)
skip: [shellcheck, actionlint, yamllint]
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,9 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
args: [-d, "{extends: relaxed, rules: {line-length: {max: 150}}}"]
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- New inputs: `wait-for-ready`, `health-endpoint`, `wait-timeout`, `wait-interval`
- Polls deployment URL until HTTP 2xx/3xx or timeout
- PR comment only appears after deployment is healthy (when combined with `comment-on-pr`)
- **deploy** action: QR code in PR comment
- New input: `qr-code` (default: `false`)
- QR code for easy mobile testing of preview deployments
- Generated locally using `qrencode` (no external API calls, privacy-friendly)

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

### Internal
- Added justfile for common development tasks
- Added pre-commit.ci configuration (weekly autoupdates, skip duplicates with CI)

### Fixed
- ShellCheck warnings: properly quoted GITHUB_OUTPUT
- Actionlint configuration to only lint workflow files
Expand Down
11 changes: 9 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ Thank you for your interest in contributing to ZAD Actions!

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

### Setting Up Pre-commit Hooks

Expand All @@ -32,10 +35,14 @@ pre-commit install

### Testing Locally

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

```bash
pre-commit run --all-files
# List available commands
just

# Run linting
just lint
```

### Testing in a Workflow
Expand Down
5 changes: 5 additions & 0 deletions deploy/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Deploys a container image to ZAD Operations Manager.
| `health-endpoint` | No | `/` | Endpoint to check for readiness |
| `wait-timeout` | No | `300` | Maximum wait time in seconds |
| `wait-interval` | No | `10` | Seconds between readiness checks |
| `qr-code` | No | `false` | Include QR code for mobile access (generated locally via qrencode) |

## Outputs

Expand Down Expand Up @@ -85,12 +86,16 @@ The action will create a comment like this on the PR:

> ## 🚀 Preview Deployment
>
> <img src="data:image/png;base64,..." width="100" height="100" align="right" alt="QR code">
>
> Your changes have been deployed to a preview environment:
>
> **URL:** https://web-pr85-my-project.your-domain.example.com
>
> This deployment will be automatically cleaned up when the PR is closed.

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`.

On subsequent deployments to the same PR, the existing comment is updated instead of creating a new one.

### Use with GitHub Environment
Expand Down
35 changes: 28 additions & 7 deletions deploy/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ inputs:
description: 'Seconds between readiness checks'
required: false
default: '10'
qr-code:
description: 'Include QR code in PR comment for mobile access (generated locally via qrencode)'
required: false
default: 'false'

outputs:
url:
Expand Down Expand Up @@ -226,6 +230,22 @@ runs:
echo "::error::Deployment did not become ready within ${WAIT_TIMEOUT}s"
exit 1

- name: Generate QR code
id: qr
if: inputs.qr-code == 'true' && inputs.comment-on-pr == 'true' && github.event_name == 'pull_request'
shell: bash
env:
DEPLOYMENT_URL: ${{ steps.deploy.outputs.url }}
run: |
sudo apt-get install -y qrencode >/dev/null 2>&1 || true
if command -v qrencode &> /dev/null; then
QR_BASE64=$(qrencode -o - -t PNG -s 4 -m 1 "$DEPLOYMENT_URL" | base64 -w0)
IMG="<img src='data:image/png;base64,${QR_BASE64}' width='100' height='100' align='right' alt='QR code'>"
echo "html=${IMG}" >> "$GITHUB_OUTPUT"
else
echo "Warning: qrencode not available, skipping QR code"
fi

- name: Comment on PR
if: inputs.comment-on-pr == 'true' && github.event_name == 'pull_request'
shell: bash
Expand All @@ -235,15 +255,16 @@ runs:
COMMENT_HEADER: ${{ inputs.comment-header }}
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REPOSITORY: ${{ github.repository }}
QR_HTML: ${{ steps.qr.outputs.html }}
run: |
# Build the comment body
COMMENT_BODY="${COMMENT_HEADER}

Your changes have been deployed to a preview environment:

**URL:** ${DEPLOYMENT_URL}

This deployment will be automatically cleaned up when the PR is closed."
COMMENT_BODY="${COMMENT_HEADER}"$'\n\n'
if [ -n "$QR_HTML" ]; then
COMMENT_BODY+="${QR_HTML}"$'\n\n'
fi
COMMENT_BODY+="Your changes have been deployed to a preview environment:"$'\n\n'
COMMENT_BODY+="**URL:** ${DEPLOYMENT_URL}"$'\n\n'
COMMENT_BODY+="This deployment will be automatically cleaned up when the PR is closed."

# Check for existing comment from this action (identified by header)
EXISTING_COMMENT_ID=$(gh api "repos/${GITHUB_REPOSITORY}/issues/${PR_NUMBER}/comments" \
Expand Down
7 changes: 7 additions & 0 deletions justfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[private]
default:
@just --list

# Run pre-commit hooks on all files
lint:
pre-commit run --all-files