Skip to content

GHA: move peter-evans/create-pull-request to GH CLI #66

GHA: move peter-evans/create-pull-request to GH CLI

GHA: move peter-evans/create-pull-request to GH CLI #66

Workflow file for this run

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: 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=diff-result.txt
cat 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: Create PR Content
run: |
echo "prContent<<EOF" >> $GITHUB_ENV
echo "**Problem:**" >> $GITHUB_ENV
echo "Harvester base OS needs to update." >> $GITHUB_ENV
echo "" >> $GITHUB_ENV
echo "**Solution:**" >> $GITHUB_ENV
echo "Bump OS image to [${{ 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 "" >> $GITHUB_ENV
echo "**More info:**" >> $GITHUB_ENV
cat diff-result.txt >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Create installer PR
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
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: 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
<<<<<<< HEAD

Check failure on line 107 in .github/workflows/installer-pr.yml

View workflow run for this annotation

GitHub Actions / .github/workflows/installer-pr.yml

Invalid workflow file

You have an error in your yaml syntax on line 107
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:**
**Test plan:**
=======
env:
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
run: |
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 }} \
>>>>>>> 6013937 (GHA: move peter-evans/create-pull-request to GH CLI)