fix: use default token for container push workflow#5
Conversation
There was a problem hiding this comment.
Pull Request Overview
This PR introduces a GitHub Actions workflow to automatically publish Docker images to GitHub Container Registry (GHCR) when releases are created. The workflow uses the default GITHUB_TOKEN for authentication, which aligns with GitHub's recommended practices for GHCR authentication.
Key changes:
- Added automated Docker image publishing triggered on release creation
- Configured proper permissions for package registry access
- Implemented semantic versioning with major version and latest tags
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| VERSION=${GITHUB_REF_NAME#v} | ||
| MAJOR=$(echo $VERSION | cut -d. -f1) |
There was a problem hiding this comment.
The version extraction logic doesn't validate the format or handle edge cases. If GITHUB_REF_NAME doesn't start with 'v' or isn't in semver format (e.g., 'v1.2.3'), this will produce unexpected results. Consider adding validation to ensure the ref name matches expected semver pattern before extraction.
| VERSION=${GITHUB_REF_NAME#v} | |
| MAJOR=$(echo $VERSION | cut -d. -f1) | |
| # Validate that GITHUB_REF_NAME matches 'vX.Y.Z' where X, Y, Z are numbers | |
| if [[ ! "$GITHUB_REF_NAME" =~ ^v([0-9]+)\.([0-9]+)\.([0-9]+)$ ]]; then | |
| echo "Error: GITHUB_REF_NAME ('$GITHUB_REF_NAME') is not in 'vX.Y.Z' semver format." | |
| exit 1 | |
| fi | |
| VERSION="${GITHUB_REF_NAME#v}" | |
| MAJOR="$(echo "$VERSION" | cut -d. -f1)" |
| ghcr.io/${{ github.repository_owner }}/node-playwright-base-image:${{ env.VERSION }} | ||
| ghcr.io/${{ github.repository_owner }}/node-playwright-base-image:${{ env.MAJOR }} | ||
| ghcr.io/${{ github.repository_owner }}/node-playwright-base-image:latest No newline at end of file |
There was a problem hiding this comment.
The image name 'node-playwright-base-image' is hardcoded in three places. Consider extracting it to an environment variable at the workflow level to reduce duplication and make future updates easier.
4ed9cb1 to
edbe975
Compare
No description provided.