From c25cddb32bc28965146e92361c6affa03eb8c048 Mon Sep 17 00:00:00 2001 From: MrMeeb Date: Sun, 11 Feb 2024 12:20:53 +0000 Subject: [PATCH] Initial commit --- .gitea/workflows/build-develop.yaml | 49 +++++++++++++++++++++++++++++ Dockerfile | 35 +++++++++++++++++++++ README.md | 1 + renovate.json | 7 +++++ 4 files changed, 92 insertions(+) create mode 100644 .gitea/workflows/build-develop.yaml create mode 100644 Dockerfile create mode 100644 README.md create mode 100644 renovate.json diff --git a/.gitea/workflows/build-develop.yaml b/.gitea/workflows/build-develop.yaml new file mode 100644 index 0000000..dfba0b5 --- /dev/null +++ b/.gitea/workflows/build-develop.yaml @@ -0,0 +1,49 @@ +name: Build Develop Image +on: + push: + branches: + - 'develop' + +env: + FULL_TAG: git.mrmeeb.stream/mrmeeb/gitea-act-runner:develop + DISCORD_COLOUR: ${{ job.status == success && '#48f442' || '#f44336' }} + DISCORD_STATE: ${{ job.status == success && 'succeeded' || 'failed' }} + +jobs: + "Build Image": + runs-on: ubuntu-docker-latest + steps: + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Login to Gitea Container Registry + uses: docker/login-action@v3 + with: + registry: git.mrmeeb.stream + username: ${{ secrets.GT_USERNAME }} + password: ${{ secrets.GT_TOKEN }} + - name: Build and push + uses: docker/build-push-action@v5 + with: + push: true + platforms: linux/amd64,linux/arm64 + tags: ${{ env.FULL_TAG }} + provenance: false + "Notify": + runs-on: ubuntu-docker-latest + if: ${{ always() }} + needs: ["Build Image"] + steps: + - name: Notify of outcome + uses: appleboy/discord-action@master + if: always() + env: + DISCORD_COLOR: "${{ job.status == 'success' && '#48f442' || '#f44336' }}" + DISCORD_MESSAGE: "${{ gitea.job }} on ${{ gitea.repository }} has ${{ job.status == 'success' && 'succeeded' || 'failed.' }}" + with: + webhook_id: ${{ secrets.WEBHOOK_ID }} + webhook_token: ${{ secrets.WEBHOOK_TOKEN }} + color: ${{ env.DISCORD_COLOR }} + username: "Gitea Bot" + message: ${{ env.DISCORD_MESSAGE }} \ No newline at end of file diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..4ffa0bc --- /dev/null +++ b/Dockerfile @@ -0,0 +1,35 @@ +FROM golang:1.21-alpine3.18 as builder +# Do not remove `git` here, it is required for getting runner version when executing `make build` +RUN apk add --no-cache make git + +RUN git clone --depth 1 --branch v0.2.6 https://gitea.com/gitea/act_runner /opt/src/act_runner +WORKDIR /opt/src/act_runner + +RUN make clean && make build + +FROM docker:dind +USER root +RUN apk add --no-cache \ + git bash supervisor + +COPY --from=builder /opt/src/act_runner/act_runner /usr/local/bin/act_runner +COPY --from=builder /opt/src/act_runner/scripts/supervisord.conf /etc/supervisord.conf +COPY --from=builder /opt/src/act_runner/scripts/run.sh /opt/act/run.sh +COPY --from=builder /opt/src/act_runner/scripts/rootless.sh /opt/act/rootless.sh + +ENV DOCKER_PRUNE_INTERVAL="0 0 * * *" + +# Add Crontab for root user +RUN echo "${DOCKER_PRUNE_INTERVAL} echo Pruning docker volumes && docker volume prune -af" > .crontab.txt && crontab .crontab.txt + +# Remove warning from supervisord about running as root +RUN sed -i '/\[supervisord\]/a user=root' /etc/supervisord.conf + +# Add Cron to supervisord +RUN echo "" >> /etc/supervisord.conf && \ + echo "[program:cron]" >> /etc/supervisord.conf && \ + echo "command=/usr/sbin/crond -f" >> /etc/supervisord.conf && \ + echo "stdout_logfile=/dev/fd/1" >> /etc/supervisord.conf && \ + echo "stdout_logfile_maxbytes=0" >> /etc/supervisord.conf + +ENTRYPOINT ["/usr/bin/supervisord", "-c", "/etc/supervisord.conf"] \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..f7adbe4 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +Act runner for Gitea. Leverages docker dind to keep child containers within the runner container, instead of running them alongside it on the host. Runs docker as root so it can do things like QEMU. Uses cron to automatically prune all docker volumes at midnight, in case they aren't tidied up by the actions themselves. \ No newline at end of file diff --git a/renovate.json b/renovate.json new file mode 100644 index 0000000..0259bd8 --- /dev/null +++ b/renovate.json @@ -0,0 +1,7 @@ +{ + "extends": [":automergeMinor", ":automergePr", ":automergeRequireAllStatusChecks", ":dependencyDashboard", ":disableRateLimiting", ":rebaseStalePrs"], + "baseBranches": ["develop"], + "major": { + "dependencyDashboardApproval": true + } +} \ No newline at end of file