# Build + push the API and web container images to the git.mancinas.io registry. # # Two images from this one repo: # git.mancinas.io/rmancinas/jorgecuadros-api # git.mancinas.io/rmancinas/jorgecuadros-web # # Comprehensive versioning (docker/metadata-action). Every build pushes a set # of tags so an image is addressable at several granularities: # - vX.Y.Z / vX.Y when the trigger is a git tag vX.Y.Z (releases) # - the branch that was pushed (e.g. master, feat-foo) # - sha- immutable per-commit id, always present # - latest only on the default branch (master) # The same version string + commit + build date are baked into the image as # ARG/ENV (APP_VERSION / GIT_SHA / BUILD_DATE) and as OCI labels, so a running # container can report exactly what is deployed. # # Release flow: git tag v1.2.0 && git push origin v1.2.0 -> versioned images. name: Build and Push Images on: push: branches: [master] tags: ["v*"] paths: - "apps/**" - "packages/**" - "docker/**" - "package.json" - "pnpm-lock.yaml" - ".gitea/workflows/build.yml" workflow_dispatch: env: REGISTRY: git.mancinas.io jobs: build: name: Build ${{ matrix.image }} runs-on: docker container: image: docker:27-dind options: --privileged permissions: contents: read packages: write strategy: fail-fast: false matrix: include: - image: jorgecuadros-api dockerfile: docker/api.Dockerfile - image: jorgecuadros-web dockerfile: docker/web.Dockerfile steps: - name: Install Node.js for actions run: apk add --no-cache nodejs npm - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 - uses: docker/login-action@v3 with: registry: ${{ env.REGISTRY }} username: ${{ secrets.REGISTRY_USERNAME }} password: ${{ secrets.REGISTRY_PASSWORD }} - id: meta uses: docker/metadata-action@v5 with: images: ${{ env.REGISTRY }}/${{ github.repository_owner }}/${{ matrix.image }} tags: | type=semver,pattern={{version}} type=semver,pattern={{major}}.{{minor}} type=ref,event=branch type=sha,format=short,prefix=sha- type=raw,value=latest,enable={{is_default_branch}} - uses: docker/build-push-action@v5 with: context: . file: ${{ matrix.dockerfile }} push: true tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} platforms: linux/amd64 build-args: | APP_VERSION=${{ steps.meta.outputs.version }} GIT_SHA=${{ github.sha }} BUILD_DATE=${{ fromJSON(steps.meta.outputs.json).labels['org.opencontainers.image.created'] }}