diff --git a/docker-build/action.yml b/docker-build/action.yml new file mode 100644 index 0000000..3819e03 --- /dev/null +++ b/docker-build/action.yml @@ -0,0 +1,53 @@ +name: Docker Build and Push +description: Build and push Docker image to Forgejo registry + +inputs: + image_name: + required: true + description: Docker image name (e.g. org/repo) + context: + default: "." + description: Build context path + dockerfile: + default: "./Dockerfile" + description: Dockerfile path + registry_auth: + required: true + description: Base64-encoded registry credentials (user:token) + +runs: + using: composite + steps: + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: docker + + - name: Configure registry auth + if: github.event_name != 'pull_request' + shell: bash + run: | + mkdir -p ~/.docker + printf '{"auths":{"git.vodyanoysh.ru":{"auth":"%s"}}}' "${{ inputs.registry_auth }}" > ~/.docker/config.json + + - name: Extract metadata + id: meta + uses: docker/metadata-action@v5 + with: + images: git.vodyanoysh.ru/${{ inputs.image_name }} + flavor: | + latest=true + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=sha,prefix=sha- + + - name: Build and push + uses: docker/build-push-action@v5 + with: + context: ${{ inputs.context }} + file: ${{ inputs.dockerfile }} + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }}