Skip to content

Build rootfs images #48

Build rootfs images

Build rootfs images #48

Workflow file for this run

name: "Build rootfs images"
on:
workflow_dispatch:
inputs:
GIT_REPO:
description: 'Repo (owner/repo)'
required: true
default: 'kernelci/kernelci-core'
GIT_BRANCH:
description: 'Branch'
required: true
default: 'main'
ROOTFS_NAME:
description: 'Rootfs name'
required: true
default: 'bookworm'
ROOTFS_ARCH:
description: 'Rootfs architecture'
required: true
default: 'arm64'
ROOTFS_DESTINATION:
description: 'Rootfs destination'
required: true
type: choice
options:
- 'staging'
- 'production'
env:
ROOTFS_NAME: ${{ github.event.inputs.ROOTFS_NAME }}
ROOTFS_ARCH: ${{ github.event.inputs.ROOTFS_ARCH }}
ROOTFS_DESTINATION: ${{ github.event.inputs.ROOTFS_DESTINATION }}
USER_GIT_REPO: ${{ github.event.inputs.GIT_REPO }}
USER_GIT_BRANCH: ${{ github.event.inputs.GIT_BRANCH }}
jobs:
rootfs-build:
# only selected people can trigger this job
if: contains('["nuclearcat","JenySadadia","a-wai","broonie","laura-nao","pawiecz","musamaanjum","nfraprado"]', github.actor)
runs-on: ubuntu-22.04
environment: deploysecrets
steps:
- name: Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_CHANNEL: 'bot'
with:
status: 'started'
author_name: ${{ github.actor }}
title: 'ROOTFS Build'
text: 'ROOTFS Build started'
- name: Checkout kernelci-deploy
uses: actions/checkout@v4
with:
repository: kernelci/kernelci-deploy
path: kernelci-deploy
ref: 'main'
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ env.USER_GIT_REPO }}
ref: ${{ env.USER_GIT_BRANCH }}
submodules: recursive
fetch-depth: 0
path: kernelci-deploy/tools/kernelci-core
- name: Prepare necessary tools
run: |
sudo apt-get update
sudo apt-get remove containerd.io
sudo apt-get install -y python3-pip git docker.io python3-docker
- name: run rootfs build
run: |
cd kernelci-deploy/tools;sudo ./kci-rootfs.py --arch $ROOTFS_ARCH --name $ROOTFS_NAME
- name: set rootfs env variables
run: |
ROOTFS_DIR=$(find kernelci-deploy/tools -type d -name _install_)
echo "ROOTFS_DIR=$ROOTFS_DIR" >> $GITHUB_ENV
echo "ROOTFS_TIMECODE=$(date +%Y%m%d.0)" >> $GITHUB_ENV
- name: Copy files via scp to staging
if: ${{ env.ROOTFS_DESTINATION == 'staging' }}
uses: appleboy/[email protected]
with:
host: ${{ secrets.STAGING_HOST }}
username: ${{ secrets.STAGING_USERNAME }}
key: ${{ secrets.STAGING_KEY }}
port: ${{ secrets.STAGING_PORT }}
source: "${{ env.ROOTFS_DIR }}/*"
target: ${{ secrets.STAGING_DIR }}/${{ env.ROOTFS_NAME }}/${{ env.ROOTFS_TIMECODE }}/${{ env.ROOTFS_ARCH }}
strip_components: 8
- name: Copy files via scp to production
if: ${{ env.ROOTFS_DESTINATION == 'production' }}
uses: appleboy/[email protected]
with:
host: ${{ secrets.PRODUCTION_HOST }}
username: ${{ secrets.PRODUCTION_USERNAME }}
key: ${{ secrets.PRODUCTION_KEY }}
port: ${{ secrets.PRODUCTION_PORT }}
source: "${{ env.ROOTFS_DIR }}/*"
target: ${{ secrets.PRODUCTION_DIR }}/${{ env.ROOTFS_NAME }}/${{ env.ROOTFS_TIMECODE }}/${{ env.ROOTFS_ARCH }}
strip_components: 8
- name: print out published rootfs
run: |
echo "FINAL_MSG=Rootfs build completed: ${{ secrets.STAGING_URL }}/${{ env.ROOTFS_NAME }}/${{ env.ROOTFS_TIMECODE }}/${{ env.ROOTFS_ARCH }}" >> $GITHUB_ENV
cat $GITHUB_ENV|grep FINAL_MSG
- name: Slack notification
uses: rtCamp/action-slack-notify@v2
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_CHANNEL: 'bot'
with:
status: 'completed'
author_name: ${{ github.actor }}
title: 'ROOTFS Build completed'
text: ${{ env.FINAL_MSG }}