URL Updates #12
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker Package | |
| on: | |
| push: | |
| branches: | |
| - master | |
| - main | |
| tags: | |
| - "v*.*.*" | |
| workflow_dispatch: | |
| permissions: | |
| contents: read | |
| packages: write | |
| concurrency: | |
| group: docker-package-${{ github.ref }} | |
| cancel-in-progress: false | |
| jobs: | |
| publish-ghcr: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 24 | |
| - name: Resolve image and package version | |
| id: vars | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| OWNER="$(echo "${GITHUB_REPOSITORY_OWNER}" | tr '[:upper:]' '[:lower:]')" | |
| IMAGE="$(basename "${GITHUB_REPOSITORY}" | tr '[:upper:]' '[:lower:]')" | |
| VERSION="$(node -p "require('./package.json').version")" | |
| VERSION="$(echo "$VERSION" | xargs)" | |
| if [ -z "$VERSION" ]; then | |
| echo "::error::package.json version is empty." | |
| exit 1 | |
| fi | |
| if [[ ! "$VERSION" =~ ^[0-9]+\.[0-9]+\.[0-9]+([-.][0-9A-Za-z.-]+)?$ ]]; then | |
| echo "::error::Invalid package.json version: '$VERSION'" | |
| exit 1 | |
| fi | |
| echo "owner=$OWNER" >> "$GITHUB_OUTPUT" | |
| echo "image=$IMAGE" >> "$GITHUB_OUTPUT" | |
| echo "version_tag=v${VERSION}" >> "$GITHUB_OUTPUT" | |
| - name: Set up QEMU | |
| uses: docker/setup-qemu-action@v3 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@v3 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ github.token }} | |
| - name: Generate image metadata | |
| id: meta | |
| uses: docker/metadata-action@v5 | |
| with: | |
| images: ghcr.io/${{ steps.vars.outputs.owner }}/${{ steps.vars.outputs.image }} | |
| tags: | | |
| type=raw,value=latest,enable={{is_default_branch}} | |
| type=raw,value=${{ steps.vars.outputs.version_tag }} | |
| labels: | | |
| org.opencontainers.image.source=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.url=${{ github.server_url }}/${{ github.repository }} | |
| org.opencontainers.image.revision=${{ github.sha }} | |
| - name: Build and push image package | |
| uses: docker/build-push-action@v6 | |
| with: | |
| context: . | |
| file: ./Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| build-args: | | |
| RUN_TESTS=false | |
| cache-from: type=gha | |
| cache-to: type=gha,mode=max | |
| - name: Show package location | |
| env: | |
| IMAGE_OWNER: ${{ steps.vars.outputs.owner }} | |
| IMAGE_NAME: ${{ steps.vars.outputs.image }} | |
| REPOSITORY_OWNER: ${{ github.repository_owner }} | |
| REPOSITORY_NAME: ${{ github.event.repository.name }} | |
| shell: bash | |
| run: | | |
| set -euo pipefail | |
| echo "Package: ghcr.io/${IMAGE_OWNER}/${IMAGE_NAME}" | |
| echo "Org packages page: https://github.com/orgs/${REPOSITORY_OWNER}/packages?repo_name=${REPOSITORY_NAME}" |