Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update pr creation v1.5 #188

Merged
136 changes: 80 additions & 56 deletions .github/workflows/installer-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,13 @@ jobs:
runs-on: ubuntu-latest
container:
image: registry.suse.com/bci/bci-base:15.5
steps:
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
Expand All @@ -35,48 +41,56 @@ jobs:
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=diff-result.txt
container-diff diff daemon://docker.io/$BASE_OS_IMAGE daemon://docker.io/${{ env.IMAGE_NAME }} --type=rpm --output=/tmp/diff-result.txt
cat diff-result.txt
- name: Set diff result to environment variable
run: |
echo "packagesDiff<<EOF" >> $GITHUB_ENV
cat diff-result.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- 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: Create installer PR
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.BOT_TOKEN }}
commit-message: Bump OS ${{ inputs.tag }}
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
team-reviewers: os
signoff: false
branch: bump-os-${{ inputs.tag }}
delete-branch: true
title: 'Bump OS ${{ inputs.tag }}'
draft: false
body: |
**Problem:**
Harvester base OS needs to update.

**Solution:**
Bump OS image to [${{ env.IMAGE_NAME }}](https://github.com/harvester/os2/releases/tag/${{ inputs.tag }}).

**Related Issue:**

**Test plan:**
- 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

**More info:**
```
${{ env.packagesDiff }}
```
- 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
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
Expand All @@ -92,26 +106,36 @@ jobs:
- 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: Create Addons PR
uses: peter-evans/create-pull-request@v5
with:
token: ${{ secrets.BOT_TOKEN }}
commit-message: Bump nvidia-driver-toolkit ${{ inputs.tag }}
committer: GitHub <[email protected]>
author: ${{ github.actor }} <${{ github.actor }}@users.noreply.github.com>
team-reviewers: os
signoff: false
branch: bump-nv-driver-${{ inputs.tag }}
delete-branch: true
title: 'Bump nvidia-driver-toolkit ${{ inputs.tag }}'
draft: false
body: |
**Problem:**
The nvidia driver toolkit needs to update.

**Solution:**
Bump nvidia driver toolkit image as related baseos [${{ env.IMAGE_NAME }}](https://github.com/harvester/os2/releases/tag/${{ inputs.tag }}).

**Related Issue:**
- 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

**Test plan:**
- 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
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 }}"