Skip to content

Commit

Permalink
feat(workflows): Add staging building script, updates
Browse files Browse the repository at this point in the history
We need also to add generation of API and PIPELINE docker
images, so staging environment can use updated images.

Signed-off-by: Denys Fedoryshchenko <[email protected]>
  • Loading branch information
nuclearcat committed Aug 13, 2024
1 parent 91289e4 commit c4b8092
Show file tree
Hide file tree
Showing 2 changed files with 63 additions and 18 deletions.
56 changes: 39 additions & 17 deletions .github/workflows/docker_images.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@ name: 'Reusable workflow compiler and misc docker images build'
on:
workflow_call:
inputs:
GIT_REPO:
GIT_OWNER:
type: string
description: 'Repo (owner/repo)'
description: 'Repo (owner), for ex: kernelci/kernelci-core owner is kernelci'
required: true
default: 'kernelci/kernelci-core'
default: 'kernelci'
GIT_BRANCH:
type: string
description: 'Branch'
required: true
default: 'main'

env:
USER_GIT_REPO: ${{ github.event.inputs.GIT_REPO }}
USER_GIT_BRANCH: ${{ github.event.inputs.GIT_BRANCH }}
USER_GIT_OWNER: ${{ inputs.GIT_OWNER }}
USER_GIT_BRANCH: ${{ inputs.GIT_BRANCH }}

jobs:
docker-compiler-build:
Expand All @@ -36,7 +36,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v4
with:
repository: ${{ env.USER_GIT_REPO }}
repository: ${{ env.USER_GIT_OWNER }}/kernelci-core
ref: ${{ env.USER_GIT_BRANCH }}
submodules: recursive
fetch-depth: 0
Expand Down Expand Up @@ -90,14 +90,27 @@ jobs:
runs-on: ubuntu-22.04
environment: deploydocker
steps:
- name: Checkout
- name: Checkout kernelci-core
uses: actions/checkout@v4
with:
repository: ${{ env.USER_GIT_REPO }}
repository: ${{ env.USER_GIT_OWNER }}/kernelci-core
ref: ${{ env.USER_GIT_BRANCH }}
submodules: recursive
fetch-depth: 0
path: kernelci-core
- name: Checkout kernelci-pipeline
uses: actions/checkout@v4
with:
repository: ${{ env.USER_GIT_OWNER }}/kernelci-pipeline
ref: ${{ env.USER_GIT_BRANCH }}
fetch-depth: 0
path: kernelci-pipeline
- name: Checkout kernelci-api
uses: actions/checkout@v4
with:
repository: ${{ env.USER_GIT_OWNER }}/kernelci-api
ref: ${{ env.USER_GIT_BRANCH }}
fetch-depth: 0
path: kernelci-api
- name: Prepare necessary tools
run: |
sudo apt-get update
Expand All @@ -117,16 +130,25 @@ jobs:
if: ${{ env.USER_GIT_BRANCH == 'main' }}
run: |
cd kernelci-core
export core_rev=$(git rev-parse HEAD)
export core_url=$(git remote get-url origin)
kci_arg="build --push --build-arg core_rev=$core_rev --prefix=ghcr.io/${{ github.actor }}/ --build-arg core_url=$core_url"
core_rev=$(git show --pretty=format:%H -s origin/${{ env.USER_GIT_BRANCH }})
cd ../kernelci-api
api_rev=$(git show --pretty=format:%H -s origin/${{ env.USER_GIT_BRANCH }})
cd ../kernelci-pipeline
pipeline_rev=$(git show --pretty=format:%H -s origin/${{ env.USER_GIT_BRANCH }})
cd ..
rev_arg="--build-arg core_rev=$core_rev --build-arg api_rev=$api_rev --build-arg pipeline_rev=$pipeline_rev"
kci_arg="build --push $rev_arg --prefix=ghcr.io/${{ github.actor }}/"
./kci docker $kci_arg ${{ matrix.kcicmd }}
- name: build base kernelci docker image for other branches
if: ${{ env.USER_GIT_BRANCH != 'main' }}
run: |
cd kernelci-core
export core_rev=$(git rev-parse HEAD)
export core_url=$(git remote get-url origin)
kci_arg="build --push --build-arg core_rev=$core_rev --prefix=ghcr.io/${{ github.actor }}/staging- --build-arg core_url=$core_url"
./kci docker $kci_arg ${{ matrix.kcicmd }}
core_rev=$(git show --pretty=format:%H -s origin/${{ env.USER_GIT_BRANCH }})
cd ../kernelci-api
api_rev=$(git show --pretty=format:%H -s origin/${{ env.USER_GIT_BRANCH }})
cd ../kernelci-pipeline
pipeline_rev=$(git show --pretty=format:%H -s origin/${{ env.USER_GIT_BRANCH }})
cd ..
rev_arg="--build-arg core_rev=$core_rev --build-arg api_rev=$api_rev --build-arg pipeline_rev=$pipeline_rev"
kci_arg="build --push $rev_arg --prefix=ghcr.io/${{ github.actor }}/staging-"
./kci docker $kci_arg ${{ matrix.kcicmd }}
25 changes: 24 additions & 1 deletion .github/workflows/staging.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,31 @@ on:
workflow_dispatch:

jobs:
prepare-staging-branches:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: 'kernelci/kernelci-deploy'
ref: 'main'
fetch-depth: 0
path: kernelci-deploy
- name: Prepare necessary tools
run: |
export DEBIAN_FRONTEND=noninteractive
sudo apt-get update
sudo apt-get install -y python3-pip git
pip3 install --upgrade pip
- name: Prepare staging branches
run: |
cd kernelci-deploy/tools
./kci-pending.py kernelci-core
./kci-pending.py kernelci-api
./kci-pending.py kernelci-pipeline
call-docker-build:
needs: prepare-staging-branches
uses: ./.github/workflows/docker_images.yml
with:
GIT_REPO: 'kernelci/kernelci-core'
GIT_OWNER: 'kernelci'
GIT_BRANCH: 'staging.kernelci.org'

0 comments on commit c4b8092

Please sign in to comment.