Skip to content

Commit

Permalink
gha: Split the Kata Containers CI workflow
Browse files Browse the repository at this point in the history
We've been facing some issues in order to properly run, in a safe way,
the workflows for the Kata Containers CI.

This happens as the `pull_request` target doesn't allow passing any
secrets to workflows; and the `pull_request_target` workflow, which
allows passing the secrets, doesn't run on the PR itself but rather on
the target PR branch. :-/

https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
proposes a reasonable solution, which I'm trying to mimic here.

Signed-off-by: Fabiano Fidêncio <[email protected]>
  • Loading branch information
fidencio committed Apr 4, 2023
1 parent 1c6d7cb commit 792fe6f
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 51 deletions.
9 changes: 9 additions & 0 deletions .github/workflows/build-kata-static-tarball.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
name: CI | Build Kata Containers artefacts
on:
pull_request

jobs:
build-kata-static-tarball-amd64:
uses: ./.github/workflows/build-kata-static-tarball-amd64.yaml
with:
tarball-suffix: -${{ github.sha }}
37 changes: 0 additions & 37 deletions .github/workflows/ci-on-push.yaml

This file was deleted.

19 changes: 19 additions & 0 deletions .github/workflows/publish-kata-deploy-payload.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: CI | Publish kata-deploy payload
on:
workflow_run:
workflows:
- CI | Build Kata Containers artefacts
types:
- completed

jobs:
publish-kata-deploy-payload-amd64:
if: ${{ github.event.workflow_run.conclusion == 'success' }}
uses: ./.github/workflows/publish-kata-deploy-payload-amd64.yaml
with:
tarball-suffix: -${{ github.event.workflow_run.head_sha }}
registry: ghcr.io
repo: ${{ github.repository_owner }}/kata-deploy-ci
tag: -${{ github.event.workflow_run.head_sha }}-amd64
quay-io-login-continue-on-error: true
secrets: inherit
25 changes: 11 additions & 14 deletions .github/workflows/run-k8s-tests-on-aks.yaml
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
name: CI | Run kubernetes tests on AKS
on:
workflow_call:
inputs:
registry:
required: true
type: string
repo:
required: true
type: string
tag:
required: true
type: string
workflow_run:
workflows:
- CI | Publish kata-deploy payload
types:
- completed

env:
ci_image: ghcr.io/kata-containers/kata-deploy-ci/${{ github.event.pull_request.number }}-${{ github.event.pull_request.head.sha }}-amd64

jobs:
create-aks:
Expand Down Expand Up @@ -54,13 +51,13 @@ jobs:
- name: Download credentials for the Kubernetes CLI to use them
run: |
az aks get-credentials -g "kataCI" -n ${{ github.event.pull_request.number }}-${{ github.sha }}-${{ matrix.vmm }}-amd64
az aks get-credentials -g "kataCI" -n -${{ github.event.workflow_run.head_sha }}-${{ matrix.vmm }}-amd64
- name: Deploy kata-deploy
run: |
sed -i -e "s|quay.io/kata-containers/kata-deploy:latest|${{ inputs.registry }}/${{ inputs.repo }}:${{ inputs.tag }}|g" tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml
sed -i -e "s|quay.io/kata-containers/kata-deploy:latest|$ci_image|g" tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml
cat tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml
cat tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml | grep "${{ inputs.registry }}/${{ inputs.repo }}:${{ inputs.tag }}" || die "Failed to setup the tests image"
cat tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml | grep "$ci_image" || die "Failed to setup the tests image"
kubectl apply -f tools/packaging/kata-deploy/kata-rbac/base/kata-rbac.yaml
kubectl apply -f tools/packaging/kata-deploy/kata-deploy/base/kata-deploy.yaml
Expand Down

0 comments on commit 792fe6f

Please sign in to comment.