Files
Django_kube/.gitea/workflows/dockerfile_runner.yaml
T
pi-ux-ce c5b7e9dcde
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 5m55s
moving the env variables
2026-03-17 10:13:24 +00:00

122 lines
4.2 KiB
YAML

name: Gitea Actions Demo
run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
on:
push:
branches:
- main
paths-ignore:
- 'django_testing/dockerfile'
issue_comment:
types: [created]
jobs:
Explore-Gitea-Actions:
env:
RUNNER_TOOL_CACHE: /toolcache
container:
image: gitea.tryton.geeraert.eu/pi-ux-ce/custom-runner-debian-slim:1.0.6
volumes:
- act-toolcache:/opt/hostedtoolcache # this is where Runner store their cache default
runs-on: host-runner
steps:
- run: echo "🔎 The name of your branch is ${{ gitea.ref }} and your repository is ${{ gitea.repository }}."
- name: restore git folder if exist
run: if [ -d "/opt/hostedtoolcache/${{ github.event.repository.name }}/" ]; then cp -r /opt/hostedtoolcache/${{ github.event.repository.name }}/ ${{ gitea.workspace }}; fi
- name: Check Docker Version
run: whereis docker
- name: Check out repository code
uses: actions/checkout@v4
clean: false
fetch-depth: 1
ref: 'main'
# - name: Manually check out repository code
# run: cd ${{ gitea.workspace }} ; git pull origin main
- run: echo "💡 The ${{ gitea.repository }} repository has been cloned to the runner."
- name: List files in the repository
run: |
ls ${{ gitea.workspace }}
- name: Compute next version
id: versioning
run: |
latest="${{ vars.VERSION }}"
next_version=$(echo "$latest" | awk -F. -v OFS=. '{$NF += 1 ; print}')
echo "next_version=$next_version" >> $GITHUB_ENV
echo "Variables used :"
echo "------------------------------------------------"
echo "Next version: $next_version"
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /opt/hostedtoolcache/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: inject cache into docker
uses: reproducible-containers/buildkit-cache-dance@v3.1.0
with:
cache-source: /opt/hostedtoolcache/pip
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to gitea
uses: docker/login-action@v3
with:
registry: gitea.tryton.geeraert.eu
username: ${{ secrets.USERNAME_GITEA }}
password: ${{ secrets.PASSWORD_GITEA }}
- name: Build and push
uses: docker/build-push-action@v6
with:
push: true
build-args: |
ALLOWED_HOSTS='django.tryton.geeraert.eu'
DEBUG='True'
tags: |
gitea.tryton.geeraert.eu/pi-ux-ce/django-python:latest
gitea.tryton.geeraert.eu/pi-ux-ce/django-python:${{ env.next_version }}
cache-from: type=local,src=/opt/hostedtoolcache/.buildx-cache
cache-to: type=local,dest=/opt/hostedtoolcache/.buildx-cache-new,mode=max
- name: Move cache
run: |
rm -rf /opt/hostedtoolcache/.buildx-cache
mv /opt/hostedtoolcache/.buildx-cache-new /opt/hostedtoolcache/.buildx-cache
- name: Rollout Django to force pulling the new image
uses: actions-hub/kubectl@master
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
with:
args: rollout restart deployment django -n django
- name: Rollout Celery worker to force pulling the new image
uses: actions-hub/kubectl@master
env:
KUBE_CONFIG: ${{ secrets.KUBE_CONFIG }}
with:
args: rollout restart deployment celery-worker -n django
- run: echo "🍏 This job's status is ${{ job.status }}."
- name: update version in the variable
run: |
curl -X PUT -H "Content-Type: application/json" \
--user ${{ secrets.USERNAME_GITEA }}:${{ secrets.PASSWORD_GITEA }} \
https://gitea.tryton.geeraert.eu/api/v1/repos/pi-ux-ce/${{ github.event.repository.name }}/actions/variables/VERSION \
-d "{\"Value\":\"$next_version\"}"
- name: backup git for future use
run: cp -r ${{ gitea.workspace }} /opt/hostedtoolcache/${{ github.event.repository.name }}/