-
Notifications
You must be signed in to change notification settings - Fork 106
139 lines (133 loc) · 5.61 KB
/
rootfs.yml
File metadata and controls
139 lines (133 loc) · 5.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
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:
discord-notify-start:
runs-on: ubuntu-latest
steps:
- name: Discord notification for start
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554 # 0.4.0
with:
args: 'Rootfs build started: "${{ github.event.inputs.ROOTFS_NAME }}" for architecture "${{ github.event.inputs.ROOTFS_ARCH }}" by ${{ github.actor }}'
rootfs-build:
# only selected people can trigger this job
if: contains('["nuclearcat","JenySadadia","a-wai","broonie","laura-nao","pawiecz","nfraprado","vigneshraman","bhcopeland"]', github.actor)
runs-on: ubuntu-22.04
environment: deploysecrets
steps:
- name: Checkout kernelci-deploy
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
repository: kernelci/kernelci-deploy
path: kernelci-deploy
ref: 'main'
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # 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/scp-action@ff85246acaad7bdce478db94a363cd2bf7c90345 # v1.0.0
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/scp-action@ff85246acaad7bdce478db94a363cd2bf7c90345 # v1.0.0
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@e31e87e03dd19038e411e38ae27cbad084a90661 # v2.3.3
env:
SLACK_TOKEN: ${{ secrets.SLACK_TOKEN }}
SLACK_CHANNEL: 'bot'
with:
status: 'completed'
author_name: ${{ github.actor }}
title: 'ROOTFS Build completed'
text: ${{ env.FINAL_MSG }}
discord-notify-end:
runs-on: ubuntu-latest
needs: rootfs-build
steps:
- name: Discord notification for end
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554 # 0.4.0
with:
args: 'Rootfs build completed: "${{ github.event.inputs.ROOTFS_NAME }}" for architecture "${{ github.event.inputs.ROOTFS_ARCH }}". Check the logs for more details.'
discord-notify-failure:
runs-on: ubuntu-latest
if: failure()
needs: [discord-notify-start, rootfs-build, discord-notify-end]
steps:
- name: Notify failure to Discord
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
uses: Ilshidur/action-discord@d2594079a10f1d6739ee50a2471f0ca57418b554 # 0.4.0
with:
args: 'Rootfs build failed: "${{ github.event.inputs.ROOTFS_NAME }}" for architecture "${{ github.event.inputs.ROOTFS_ARCH }}". Check the logs for more details.'