From d2a00fcd2c3b80536dcede67b69a19d4a3f810a7 Mon Sep 17 00:00:00 2001 From: felegy Date: Mon, 18 Aug 2025 13:16:06 +0000 Subject: [PATCH] + ADD github build action via kpack --- .github/workflows/cicd.yaml | 35 ++++++++++++++++ k8s/gitea-runner.yaml | 79 +++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+) create mode 100644 .github/workflows/cicd.yaml create mode 100644 k8s/gitea-runner.yaml diff --git a/.github/workflows/cicd.yaml b/.github/workflows/cicd.yaml new file mode 100644 index 0000000..1a2d63e --- /dev/null +++ b/.github/workflows/cicd.yaml @@ -0,0 +1,35 @@ +on: + push: + branches: [ main ] +jobs: + build-and-deploy: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: benjlevesque/short-sha@v3.0 + id: short-sha + with: + length: 10 + - name: Install kpack CLI + env: + KPACK_CLI_VERSION: "0.13.0" + run: | + curl -L "https://github.com/buildpacks-community/kpack-cli/releases/download/v${KPACK_CLI_VERSION}/kp-linux-amd64-${KPACK_CLI_VERSION}" -o kp + chmod +x kp + sudo mv kp /usr/local/bin/ + - name: Configure kubectl + uses: azure/k8s-set-context@v1 + with: + kubeconfig: ${{ secrets.KUBE_CONFIG }} + - name: Update kpack image + env: + SHA: ${{ github.sha }} + SHORT_SHA: ${{ steps.short-sha.outputs.sha }} + run: | + kp image patch tutorial-image --replace-additional-tag "ghcr.io/hvg-dev/php-test:sha-${SHORT_SHA}" --git-revision "${SHA}" -n test-builder + - name: Wait for build to complete + run: | + kp build logs tutorial-image -n test-builder +# - name: Update Kubernetes deployment +# run: | +# kubectl set image deployment/my-app my-app=/:${{ github.sha }} diff --git a/k8s/gitea-runner.yaml b/k8s/gitea-runner.yaml new file mode 100644 index 0000000..fbf272f --- /dev/null +++ b/k8s/gitea-runner.yaml @@ -0,0 +1,79 @@ +kind: PersistentVolumeClaim +apiVersion: v1 +metadata: + name: act-runner-vol +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi +--- +apiVersion: v1 +stringData: + # The registration token can be obtained from the web UI, API or command-line. + # You can also set a pre-defined global runner registration token for the Gitea instance via + # `GITEA_RUNNER_REGISTRATION_TOKEN`/`GITEA_RUNNER_REGISTRATION_TOKEN_FILE` environment variable. + token: Dw48WxjKe1d8ahEEu4UIUlhp7G85zEg2v8D2fXpW +kind: Secret +metadata: + name: runner-secret +type: Opaque +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + labels: + app: act-runner + name: act-runner +spec: + replicas: 1 + selector: + matchLabels: + app: act-runner + strategy: {} + template: + metadata: + labels: + app: act-runner + spec: + restartPolicy: Always + volumes: + - name: docker-certs + emptyDir: {} + - name: runner-data + persistentVolumeClaim: + claimName: act-runner-vol + containers: + - name: runner + image: gitea/act_runner:nightly + command: ["sh", "-c", "while ! nc -z localhost 2376