From 9d64499c2a441c6fb1ab50f3e9c1bb690145122e Mon Sep 17 00:00:00 2001 From: vodyanoysh Date: Fri, 24 Apr 2026 19:50:38 +0700 Subject: [PATCH] init --- .forgejo/workflows/docker-build.yml | 61 +++++++++++++++++++++++++++++ .gitignore | 1 + README.md | 29 ++++++++++++++ 3 files changed, 91 insertions(+) create mode 100644 .forgejo/workflows/docker-build.yml create mode 100644 .gitignore create mode 100644 README.md diff --git a/.forgejo/workflows/docker-build.yml b/.forgejo/workflows/docker-build.yml new file mode 100644 index 0000000..6dc0a08 --- /dev/null +++ b/.forgejo/workflows/docker-build.yml @@ -0,0 +1,61 @@ +name: Reusable Docker Build + +on: + workflow_call: + inputs: + image_name: + required: true + type: string + context: + required: false + type: string + default: "." + dockerfile: + required: false + type: string + default: "./Dockerfile" + secrets: + REGISTRY_AUTH: + required: true + +jobs: + build: + runs-on: docker + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + driver: docker + + - name: Configure registry auth + if: github.event_name != 'pull_request' + env: + REGISTRY_AUTH: ${{ secrets.REGISTRY_AUTH }} + run: | + mkdir -p ~/.docker + printf '{"auths":{"git.vodyanoysh.ru":{"auth":"%s"}}}' "$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 }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..485dee6 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea diff --git a/README.md b/README.md new file mode 100644 index 0000000..aa315ed --- /dev/null +++ b/README.md @@ -0,0 +1,29 @@ + +## Usage + +In your project's `.forgejo/workflows/build.yml`: + +```yaml +name: Build + +on: + push: + branches: [master] + pull_request: + branches: [master] + +jobs: + docker-build: + uses: vodyanoy/ci-workflows/.forgejo/workflows/docker-build.yml@master + with: + image_name: vodyanoy/your-project # required: org/repo as it appears in the registry + secrets: + REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }} + REGISTRY_TOKEN: ${{ secrets.REGISTRY_TOKEN }} +``` + +### Available workflows + +| Workflow | Trigger | Inputs | Secrets | +|---|---|---|---| +| `docker-build.yml` | `workflow_call` | `image_name` (required), `context` (default `.`), `dockerfile` (default `./Dockerfile`) | `REGISTRY_USERNAME`, `REGISTRY_TOKEN` |