Skip to content

Commit

Permalink
Merge pull request #10 from matusso/kiterunner-fix
Browse files Browse the repository at this point in the history
feat(ci): update Docker workflows for multi-architecture builds
  • Loading branch information
matusso authored Feb 5, 2025
2 parents 781fc15 + 33c2dad commit 46f5173
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 18 deletions.
82 changes: 65 additions & 17 deletions .github/workflows/kiterunner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,8 @@ env:
KR_DIR: "/usr/local/kiterunner"

jobs:
build-and-push:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]

build-and-push-amd64:
runs-on: ubuntu-latest # Native amd64 GitHub runner
steps:
- uses: actions/checkout@v4
- uses: snyk/actions/setup@master
Expand All @@ -35,28 +31,80 @@ jobs:
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Cache Docker layers
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: ${{ github.workspace }}/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
path: ${{ github.workspace }}/.build-cache
key: ${{ runner.os }}-build-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
${{ runner.os }}-build-
- name: Build and push Docker image
run: |
docker buildx build --push \
docker build --platform linux/amd64 \
--build-arg "KR_DIR=${{ env.KR_DIR }}" --build-arg "RELEASE_VERSION=${{ env.RELEASE_VERSION }}" \
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }} \
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:latest \
--platform linux/amd64,linux/arm64 ./files/kiterunner
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-amd64 \
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:latest-amd64 ./files/kiterunner
docker push ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-amd64
docker push ghcr.io/${{ github.repository_owner }}/kiterunner:latest-amd64
- name: Logout from Docker Hub
run: docker logout

build-and-push-arm64:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
- uses: snyk/actions/setup@master

- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push arm64 Docker image
run: |
docker build --platform linux/arm64 \
--build-arg "KR_DIR=${{ env.KR_DIR }}" --build-arg "RELEASE_VERSION=${{ env.RELEASE_VERSION }}" \
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-arm64 \
--tag ghcr.io/${{ github.repository_owner }}/kiterunner:latest-arm64 ./files/kiterunner
docker push ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-arm64
docker push ghcr.io/${{ github.repository_owner }}/kiterunner:latest-arm64
- name: Logout from Docker Hub
run: docker logout

create-multiarch-manifest:
needs: [build-and-push-amd64, build-and-push-arm64]
runs-on: ubuntu-latest
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create and push multi-platform manifest
run: |
docker manifest create ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }} \
--amend ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}-arm64
docker manifest create ghcr.io/${{ github.repository_owner }}/kiterunner:latest \
--amend ghcr.io/${{ github.repository_owner }}/kiterunner:latest-amd64 \
--amend ghcr.io/${{ github.repository_owner }}/kiterunner:latest-arm64
docker manifest push ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }}
docker manifest push ghcr.io/${{ github.repository_owner }}/kiterunner:latest
security-scan:
needs: create-multiarch-manifest
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Check ghcr.io/${{ github.repository_owner }}/kiterunner:${{ env.RELEASE_VERSION }} image
uses: snyk/actions/docker@master
continue-on-error: true
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/metasploit-framework.yml
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ jobs:
repository: rapid7/metasploit-framework
path: metasploit-framework
ref: ${{ env.RELEASE_VERSION }}

- name: Check ghcr.io/${{ github.repository_owner }}/metasploit-framework:${{ env.RELEASE_VERSION }} image
uses: snyk/actions/docker@master
continue-on-error: true
Expand Down

0 comments on commit 46f5173

Please sign in to comment.