commit ba3ec728bcbc50742126fd2a7c5b7f5b911221bc Author: Zee Vieira Date: Tue Nov 11 12:41:04 2025 +0100 first commit diff --git a/.gitea/workflows/docker-build.yaml b/.gitea/workflows/docker-build.yaml new file mode 100644 index 0000000..772e9a0 --- /dev/null +++ b/.gitea/workflows/docker-build.yaml @@ -0,0 +1,80 @@ +--- +name: Docker Build +on: + workflow_call: + inputs: + dockerfile: + description: 'Path to Dockerfile' + required: true + type: string + context: + description: 'Build context' + default: '.' + required: false + image: + description: 'Where to store the built image' + required: true + type: string + submodules: + description: 'Submodules pull strategy' + default: 'recursive' + required: false + type: string + user: + description: 'Git user for checkout' + default: 'automation' + required: false + type: string + token: + description: 'Git token for checkout' + required: true + type: string + outputs: + tag: + description: 'Built image tag' + value: ${{ steps.build.outputs.tag }} + image: + description: 'Built image name' + value: ${{ steps.build.outputs.image }} + sha: + description: 'Git SHA used for the build' + value: ${{ steps.build.outputs.sha }} +jobs: + build: + name: Build Docker Image + steps: + - name: Checkout repository + uses: actions/checkout@v5 + with: + submodules: ${{ inputs.submodules }} + token: "${{ inputs.token }}" + - name: Gather registry metadata + uses: docker/metadata-action@v5 + id: meta + with: + images: ${{ inputs.image }} + tags: | + type=sha,prefix=,suffix=,format=long + - name: Registry login + uses: docker/login-action@v3 + with: + registry: git.etc.nu + username: "${{ inputs.user }}" + password: "${{ inputs.token }}" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push image + uses: docker/build-push-action@v6 + id: build + with: + file: ${{ inputs.dockerfile }} + context: ${{ inputs.context }} + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=registry,ref=${{ inputs.image }}/cache + cache-to: type=registry,ref=${{ inputs.image }}/cache,mode=max + outputs: + tag: ${{ fromJSON(steps.meta.outputs.json).tags[0] }} + image: ${{ inputs.image }} + sha: ${{ gitea.sha }} diff --git a/.gitea/workflows/docker-tag-release.yaml b/.gitea/workflows/docker-tag-release.yaml new file mode 100644 index 0000000..49bd305 --- /dev/null +++ b/.gitea/workflows/docker-tag-release.yaml @@ -0,0 +1,59 @@ +--- +name: Docker Tag Release +on: + workflow_call: + inputs: + environment: + description: 'Environment to release in' + type: string + required: true + image: + description: 'Where to store the built image' + required: true + type: string + user: + description: 'Git user for checkout' + default: 'automation' + required: false + type: string + token: + description: 'Git token for checkout' + required: true + type: string + outputs: + tag: + description: 'Release image tag' + value: ${{ steps.release.outputs.tag }} + tag_name: + description: 'Release image tag name' + value: ${{ steps.release.outputs.tag_name }} +jobs: + release: + name: Release + steps: + - name: Create metadata + id: meta + run: | + echo tag_name=${{ inputs.environment }}-$(date +%F-%H%M%S)-${{ gitea.sha }} > $GITHUB_OUTPUT + - name: Registry login + uses: docker/login-action@v3 + with: + registry: git.etc.nu + username: "${{ inputs.user }}" + password: "${{ inputs.token }}" + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + with: + install: true + version: v0.26.1 + - name: Push tag + id: push + run: | + TAG=${{ inputs.image }}:${{ steps.meta.outputs.tag_name }} + docker buildx imagetools --debug create \ + --tag $TAG \ + ${{ inputs.image }}:${{ gitea.sha }} + echo tag=$TAG >> $GITHUB_OUTPUT + outputs: + tag: ${{ steps.push.outputs.tag }} + tag_name: ${{ steps.meta.outputs.tag_name }} \ No newline at end of file diff --git a/.gitea/workflows/gitea-create-release.yaml b/.gitea/workflows/gitea-create-release.yaml new file mode 100644 index 0000000..9f27f87 --- /dev/null +++ b/.gitea/workflows/gitea-create-release.yaml @@ -0,0 +1,38 @@ +--- +name: Gitea Create Release +on: + workflow_call: + inputs: + token: + description: "Token for authentication" + required: true + type: string + outputs: + name: + description: "Release name" + value: ${{ jobs.create-release.outputs.name }} + tag_name: + description: "Release tag name" + value: ${{ jobs.create-release.outputs.tag_name }} +jobs: + create-release: + name: Create Release + steps: + - id: facts + run: | + tag_name=$(date +%F-%H%M%S) + echo name="Release ${tag_name}" >> $GITHUB_OUTPUT + echo tag_name=${tag_name} >> $GITHUB_OUTPUT + - uses: https://gitea.com/actions/gitea-release-action@v1 + with: + name: ${{ steps.facts.outputs.name }} + tag_name: ${{ steps.facts.outputs.tag_name }} + body: | + Automated release triggered by push to main branch. + draft: false + prerelease: true + target_commitish: ${{ gitea.sha }} + token: ${{ inputs.token }} + outputs: + name: ${{ steps.facts.outputs.name }} + tag_name: ${{ steps.facts.outputs.tag_name }}