1
0
Fork 0
mirror of https://code.forgejo.org/forgejo/runner.git synced 2025-08-01 17:38:36 +00:00
forgejo-runner/examples/kubernetes/build.yaml
Grégoire Bellon-Gervais d871b38c8d
Improve doc and add full example for Kubernetes (#657)
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/657
Reviewed-by: earl-warren <earl-warren@noreply.code.forgejo.org>
Co-authored-by: Grégoire Bellon-Gervais <gregoire.bellon-gervais@docaposte.fr>
Co-committed-by: Grégoire Bellon-Gervais <gregoire.bellon-gervais@docaposte.fr>
2025-07-03 15:22:24 +00:00

48 lines
2.2 KiB
YAML

name: build
on:
push:
paths:
- airflow/Dockerfile # Trigger only if Dockerfile is changed
- airflow/requirements.txt # Trigger only if requirements.txt is changed
jobs:
build:
runs-on: docker
steps:
- name: Checkout the repo
uses: https://data.forgejo.org/actions/checkout@v4
- name: Extract the current airflow version from the Dockerfile and set it in a variable name airflow_version
id: extract_airflow_version
run: echo "::set-output name=airflow_version::$(grep -oP '(?<=FROM apache/airflow:)[0-9]+\.[0-9]+\.[0-9]+' airflow/Dockerfile)"
- name: Add variables
id: add-vars
run: |
echo "::set-output name=registry::${GITHUB_SERVER_URL#*//}" # built-in env variable
echo "::set-output name=repository::${GITHUB_REPOSITORY}" # built-in env variable
echo "::set-output name=app::airflow"
echo "::set-output name=context::airflow" # Dockerfile is in airflow folder, so context is airflow folder not .
echo "::set-output name=dockerfile::airflow/Dockerfile" # Dockerfile path
echo "::set-output name=tag::${{ steps.extract_airflow_version.outputs.airflow_version }}-${{ github.sha}}"
- name: Docker CLI installation
run: |
apt update
apt install -y ca-certificates curl
curl -fsSL https://get.docker.com -o get-docker.sh
sh get-docker.sh
- name: Login to Container Registry
uses: docker/login-action@v3
with:
registry: ${{ steps.add-vars.outputs.registry }}
username: ${{ secrets.USERNAME_WRITE_REPOSITORY }}
password: ${{ secrets.PASSWORD_WRITE_REPOSITORY }}
- name: Image build
run: docker build -f ${{ steps.add-vars.outputs.dockerfile }} -t ${{ steps.add-vars.outputs.registry }}/${{ steps.add-vars.outputs.repository }}:${{ steps.add-vars.outputs.app }}-${{ steps.add-vars.outputs.tag }} ${{ steps.add-vars.outputs.context }}
- name: Image push to registry
run: docker push ${{steps.add-vars.outputs.registry }}/${{steps.add-vars.outputs.repository }}:${{steps.add-vars.outputs.app }}-${{ steps.add-vars.outputs.tag }}