forked from ibuildthecloud/os2
-
Notifications
You must be signed in to change notification settings - Fork 19
149 lines (144 loc) · 5.97 KB
/
installer-pr.yml
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
140
141
142
143
144
145
146
147
148
149
on:
workflow_call:
inputs:
tag:
required: true
type: string
env:
IMAGE_NAME: rancher/harvester-os:${{ inputs.tag }}
jobs:
create-installer-pr:
runs-on: ubuntu-latest
container:
image: registry.suse.com/bci/bci-base:15.5
steps:
- name: Set up GitHub CLI
run: |
curl -sSL https://github.com/cli/cli/releases/download/v2.66.1/gh_2.66.1_linux_amd64.tar.gz -o ghcli.tar.gz
tar xzf ghcli.tar.gz
mv gh_2.66.1_linux_amd64/bin/gh /usr/local/bin/
gh --version
- name: fetch-target-version
run: |
echo "targetVersion=$(echo ${{ inputs.tag }} | cut -d'-' -f1)" >> $GITHUB_ENV
- name: Install docker
run: zypper ref && zypper -n install docker npm git
- name: Pull release image
run: |
docker pull ${{ env.IMAGE_NAME }}
- name: Install container-diff
run: |
curl -sfL https://github.com/GoogleContainerTools/container-diff/releases/download/v0.17.0/container-diff-linux-amd64 -o /usr/bin/container-diff
chmod +x /usr/bin/container-diff
- name: Get current OS image from installer
run: |
curl -sfL https://raw.githubusercontent.com/harvester/harvester-installer/${{ env.targetVersion }}/scripts/package-harvester-os -o /tmp/package-harvester-os
grep '^BASE_OS_IMAGE="rancher/harvester-os:' /tmp/package-harvester-os > /tmp/tmp-env
- name: Run container-diff
run: |
source /tmp/tmp-env
docker pull $BASE_OS_IMAGE
echo "Diff $BASE_OS_IMAGE with ${{ env.IMAGE_NAME }}..."
container-diff diff daemon://docker.io/$BASE_OS_IMAGE daemon://docker.io/${{ env.IMAGE_NAME }} --type=rpm --output=/tmp/diff-result.txt
cat /tmp/diff-result.txt
- name: Clone harvester-installer repo
uses: actions/checkout@v3
with:
repository: harvester/harvester-installer
ref: ${{ env.targetVersion }}
- name: Update os image
run: sed -i "s,^BASE_OS_IMAGE=.*,BASE_OS_IMAGE=\"${{ env.IMAGE_NAME }}\"," scripts/package-harvester-os
- name: Config PR committer
run: |
git config --global user.email "<[email protected]>"
git config --global user.name "Github"
- name: Create PR Content
run: |
{
echo "prContent<<EOF"
echo "**Problem:**"
echo "Harvester base OS needs to update."
echo ""
echo "**Solution:**"
echo "Bump OS image to [${{ env.IMAGE_NAME }}](https://github.com/harvester/os2/releases/tag/${{ inputs.tag }})."
echo ""
echo "**Related Issue:**"
echo ""
echo "**Test plan:**"
echo ""
echo "**More info:**"
echo '~~~'
cat /tmp/diff-result.txt
echo '~~~'
echo "EOF"
} >> $GITHUB_ENV
- name: Create installer PR
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
git config --global --add safe.directory $PWD
git config --local --unset http.https://github.com/.extraheader ^AUTHORIZATION:
gh auth setup-git
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit, skip PR creation."
exit 0
fi
git add .
git commit -m "Bump OS ${{ inputs.tag }}" --author="${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
git push origin HEAD:bump-os-${{ inputs.tag }}
gh pr create \
--base ${{ env.targetVersion }} \
--head bump-os-${{ inputs.tag }} \
--reviewer "harvester/os" \
--title "Bump OS ${{ inputs.tag }}" \
--body "${{ env.prContent }}"
create-addon-pr:
runs-on: ubuntu-latest
steps:
- name: fetch-target-version
run: |
echo "targetVersion=$(echo ${{ inputs.tag }} | cut -d'-' -f1)" >> $GITHUB_ENV
- name: Clone Addons repo
uses: actions/checkout@v3
with:
repository: harvester/addons
ref: ${{ env.targetVersion }}
- name: Update nvidia driver toolkit tag
run: |
sed -i "/tag:/ {N; /harvester-nvidia-driver-toolkit/ s/tag:.*\n/tag: ${{ inputs.tag }}\n/}" pkg/templates/rancherd-22-addons.yaml
- name: Config PR committer
run: |
git config --global user.email "<[email protected]>"
git config --global user.name "Github"
- name: create PR content
run: |
echo "prContent<<EOF" >> $GITHUB_ENV
echo "**Problem:**" >> $GITHUB_ENV
echo "The nvidia driver toolkit needs to update." >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "**Solution:**" >> $GITHUB_ENV
echo "Bump nvidia driver toolkit image as related baseos [${{ env.IMAGE_NAME }}](https://github.com/harvester/os2/releases/tag/${{ inputs.tag }})." >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "**Related Issue:**" >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "**Test plan:**" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Create Addons PR
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
git config --local --unset http.https://github.com/.extraheader ^AUTHORIZATION:
gh auth setup-git
if [ -z "$(git status --porcelain)" ]; then
echo "No changes to commit, skip PR creation."
exit 0
fi
git add .
git commit -m "Bump nvidia-driver-toolkit ${{ inputs.tag }}" --author="${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>"
git push origin HEAD:bump-nv-driver-${{ inputs.tag }}
gh pr create \
--base ${{ env.targetVersion }} \
--head bump-nv-driver-${{ inputs.tag }} \
--reviewer "harvester/os" \
--title "Bump nvidia-driver-toolkit ${{ inputs.tag }}" \
--body "${{ env.prContent }}"