6 Commits

Author SHA1 Message Date
2e551dc661 infra: image: fixes image_tag
All checks were successful
Gentoo Utils / build-oci-image (push) Successful in 6m48s
Gentoo Utils / build (push) Successful in 1m31s
2025-12-08 20:28:27 -06:00
da49f9a91d infra: image: fix image tag for build job
Some checks failed
Gentoo Utils / build (push) Has been cancelled
Gentoo Utils / build-oci-image (push) Has been cancelled
2025-12-08 20:24:19 -06:00
bfb0c50ab0 infra: image: build image for branches if they dont exist
Some checks failed
Gentoo Utils / build-oci-image (push) Successful in 6m19s
Gentoo Utils / build (push) Failing after 0s
2025-12-08 20:15:11 -06:00
e9da4fbf62 infra: image: fixes c35db0f
Some checks failed
Gentoo Utils / build-oci-image (push) Successful in 8s
Gentoo Utils / build (push) Failing after 0s
2025-12-08 19:50:01 -06:00
c35db0ffa0 infra: image: protect :latest tag so only the default branch can push to it
Some checks failed
Gentoo Utils / build-oci-image (push) Failing after 22s
Gentoo Utils / build (push) Has been skipped
infra: image: fix hard coded image name
2025-12-08 19:42:09 -06:00
0837e465a9 infra: image: create entrypoint script and put env sources in it 2025-12-08 19:41:46 -06:00
2 changed files with 34 additions and 11 deletions

View File

@@ -31,4 +31,6 @@ USER gentooligan
WORKDIR /workspace WORKDIR /workspace
ENTRYPOINT /bin/bash ENTRYPOINT ["/entrypoint.sh"]
CMD ["/bin/bash"]

View File

@@ -14,20 +14,39 @@ jobs:
- name: Check for changes before building - name: Check for changes before building
id: image-changes id: image-changes
# build image only if 1. changes are detected or 2. an image for the working branch doesnt exist
run: | run: |
echo "branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITEA_OUTPUT branch_name="${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
if ! git diff ${{ gitea.event.before }} ${{ gitea.sha }} --no-patch --exit-code .docker; then
echo changes_detected=true >> $GITEA_OUTPUT if [[ "$branch_name" == "${{ gitea.event.repository.default_branch }}" ]]; then
image_tag=latest
else else
echo changes_detected=false >> $GITEA_OUTPUT image_tag=$branch_name
fi fi
echo "branch_name=$branch_name" >> $GITEA_OUTPUT
# slugify
image_tag="$(echo "$image_tag" | sed -E 's/[^a-zA-Z0-9]/-/g')"
echo "image_tag=$image_tag" >> $GITEA_OUTPUT
if ! git diff ${{ gitea.event.before }} ${{ gitea.sha }} --no-patch --exit-code .docker; then
build_image=true
else
if ! docker manifest inspect git.epenguin.net/${{ gitea.repository }}:${image_tag} >/dev/null 2>&1; then
build_image=true
else
build_image=false
fi
fi
echo "build_image=$build_image" >> $GITEA_OUTPUT
cat $GITEA_OUTPUT cat $GITEA_OUTPUT
- name: Set up Docker buildx - name: Set up Docker buildx
if: steps.image-changes.outputs.changes_detected == 'true' if: steps.image-changes.outputs.build_image == 'true'
uses: docker/setup-buildx-action@v3 uses: docker/setup-buildx-action@v3
- name: Log in to Github Container Registry - name: Log in to Github Container Registry
if: steps.image-changes.outputs.changes_detected == 'true' if: steps.image-changes.outputs.build_image == 'true'
uses: docker/login-action@v3 uses: docker/login-action@v3
with: with:
registry: git.epenguin.net registry: git.epenguin.net
@@ -35,18 +54,20 @@ jobs:
password: ${{ secrets.CI_BOT_TOKEN }} password: ${{ secrets.CI_BOT_TOKEN }}
- name: Build and push - name: Build and push
if: steps.image-changes.outputs.changes_detected == 'true' if: steps.image-changes.outputs.build_image == 'true'
uses: docker/build-push-action@v6 uses: docker/build-push-action@v6
with: with:
push: true push: true
tags: git.epenguin.net/${{ gitea.repository }}:latest tags: git.epenguin.net/${{ gitea.repository }}:${{ steps.image-changes.outputs.image_tag }}
context: "{{defaultContext}}:.docker" context: "{{defaultContext}}:.docker"
outputs:
image_tag: ${{ steps.image-changes.outputs.image_tag }}
build: build:
runs-on: brutalisk runs-on: brutalisk
container:
image: git.epenguin.net/gentoo-utils/gentoo-utils-gitea:latest
needs: build-oci-image needs: build-oci-image
container:
image: git.epenguin.net/${{ gitea.repository }}:${{ needs.build-oci-image.outputs.image_tag }}
steps: steps:
- name: Checkout repo - name: Checkout repo
uses: actions/checkout@v5 uses: actions/checkout@v5