Initial commit

This commit is contained in:
MrMeeb 2024-02-11 12:20:53 +00:00
commit c25cddb32b
4 changed files with 92 additions and 0 deletions

View File

@ -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 }}

35
Dockerfile Normal file
View File

@ -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"]

1
README.md Normal file
View File

@ -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.

7
renovate.json Normal file
View File

@ -0,0 +1,7 @@
{
"extends": [":automergeMinor", ":automergePr", ":automergeRequireAllStatusChecks", ":dependencyDashboard", ":disableRateLimiting", ":rebaseStalePrs"],
"baseBranches": ["develop"],
"major": {
"dependencyDashboardApproval": true
}
}