From 2383c311cea7355b2f9732afe4fd5eb75b4c7c65 Mon Sep 17 00:00:00 2001 From: olofvndrhr Date: Tue, 5 Dec 2023 14:25:18 +0100 Subject: [PATCH] init --- .gitea/workflows/build_container.yml | 88 ++++++++++++++++++++++++++++ .gitignore | 2 + README.md | 0 3 files changed, 90 insertions(+) create mode 100644 .gitea/workflows/build_container.yml create mode 100644 .gitignore create mode 100644 README.md diff --git a/.gitea/workflows/build_container.yml b/.gitea/workflows/build_container.yml new file mode 100644 index 0000000..42e1018 --- /dev/null +++ b/.gitea/workflows/build_container.yml @@ -0,0 +1,88 @@ +name: build container + +on: + workflow_call: + inputs: + registry: + required: true + type: string + description: "registry to upload the container to" + image-name: + required: true + type: string + description: "image name of the container" + context: + required: false + type: string + description: "context location for the build" + default: "." + dockerfile: + required: false + type: string + description: "location of the dockerfile" + default: "Dockerfile" + platforms: + required: false + type: string + description: "platforms to build for" + default: "linux/amd64" + + secrets: + cr-username: + required: true + description: "registry username" + cr-password: + required: true + description: "registry password" + +jobs: + build-container: + runs-on: ubuntu-latest + steps: + - name: checkout code + uses: actions/checkout@v3 + + - name: setup qemu + uses: docker/setup-qemu-action@v2 + + - name: setup docker buildx + uses: docker/setup-buildx-action@v2 + + - name: get container metadata + uses: docker/metadata-action@v4 + id: metadata + with: + images: ${{ inputs.registry }}/${{ inputs.image-name }} + flavor: | + latest=auto + prefix= + suffix= + tags: | + type=schedule + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha + + - name: login to container registry + uses: docker/login-action@v2 + with: + registry: ${{ inputs.registry }} + username: ${{ secrets.cr-username }} + password: ${{ secrets.cr-password }} + + - name: build and push docker image @${{ inputs.platforms }} + uses: docker/build-push-action@v4 + with: + push: ${{ gitea.event_name != 'pull_request' }} + platforms: ${{ inputs.platforms }} + context: ${{ inputs.context }} + file: ${{ inputs.dockerfile }} + provenance: false + tags: ${{ steps.metadata.outputs.tags }} + labels: ${{ steps.metadata.outputs.labels }} + build-args: | + BUILD_VERSION=${{ steps.metadata.outputs.version }} + BUILD_COMMIT=${{ gitea.sha }} diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..66f8fb5 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.idea/ +.vscode/ diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29