Skip to content

Commit

Permalink
workflows/openshift-os : fixing up the initial checkout
Browse files Browse the repository at this point in the history
the base branch should be checked out initally otherwise the rebase will
fails.
Also fixup the log generation to remove the hard-coded testing-devel
Make the sources branches to a pickup menu and generate the destination
branch and the base PR branch from that to avoid errors.
  • Loading branch information
jbtrystram committed Feb 29, 2024
1 parent 72db29c commit 1909aa9
Showing 1 changed file with 40 additions and 22 deletions.
62 changes: 40 additions & 22 deletions .github/workflows/openshift-os.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,20 @@ on:
- cron: '0 0 * * *'
workflow_dispatch:
inputs:
branch-name:
# Allow overriding branch for syncs that need manual fixups
description: PR branch name
required: true
default: fcc-sync
branch:
# Allow specifying the source branch for backports
description: Source branch to use for PR
required: true
default: testing-devel
target-branch:
# Allow specifying the target branch for backports
description: Target branch to open PR against
required: true
default: master

type: choice
options:
- testing-devel
- rhcos-4.15
- rhcos-4.14
- rhcos-4.13
- rhcos-4.12
- rhcos-4.11
- rhcos-4.10
permissions:
# none at all
contents: none
Expand All @@ -30,35 +28,54 @@ jobs:
update-submodule:
name: Update fedora-coreos-config submodule
runs-on: ubuntu-latest
env:
SOURCE_BRANCH: ${{ github.event.inputs.branch }}
steps:
- name: Set branches values
run: |
case $SOURCE_BRANCH in
testing-devel)
echo "TARGET_BRANCH=master" >> $GITHUB_ENV
echo "BRANCH_NAME=fcc-sync" >> $GITHUB_ENV
;;
rhcos-*)
# split the string around the -
array=(${SOURCE_BRANCH//-/ })
OCP_VERSION=${array[1]}
echo "TARGET_BRANCH=release-${OCP_VERSION}" >> $GITHUB_ENV
echo "BRANCH_NAME=fcc-sync-${SOURCE_BRANCH}" >> $GITHUB_ENV
;;
*)
# Default branches names for on.schedule case
echo "SOURCE_BRANCH=testing-devel" >> $GITHUB_ENV
echo "TARGET_BRANCH=master" >> $GITHUB_ENV
echo "BRANCH_NAME=fcc-sync" >> $GITHUB_ENV
;;
esac
- name: Check out repository
uses: actions/checkout@v3
with:
repository: openshift/os
# We need an unbroken commit chain when pushing to the fork. Don't
# make assumptions about which commits are already available there.
fetch-depth: 0
# We need to checkout against the target branch
ref: ${{ env.TARGET_BRANCH }}

- name: Update submodule
env:
BRANCH_NAME: ${{ github.event.inputs.branch-name }}
SOURCE_BRANCH: ${{ github.event.inputs.branch }}
TARGET_BRANCH: ${{ github.event.inputs.target-branch }}
run: |
set -euxo pipefail
# Default branches names for on.schedule case
echo "BRANCH_NAME=${BRANCH_NAME:-fcc-sync}" >> $GITHUB_ENV
echo "SOURCE_BRANCH=${SOURCE_BRANCH:-testing-devel}" >> $GITHUB_ENV
echo "TARGET_BRANCH=${TARGET_BRANCH:-master}" >> $GITHUB_ENV
git submodule init
git submodule update
cd fedora-coreos-config
# the submodule init only fetch the submodule commit and the default branch `testing-devel`
git fetch origin ${SOURCE_BRANCH}
# Omit CoreOS Bot commits from the log message, since they generally
# only affect FCOS
git shortlog "HEAD..testing-devel" --perl-regexp \
git shortlog "HEAD..FETCH_HEAD" --perl-regexp \
--author='^((?!CoreOS Bot <[email protected]>).*)$' \
> $RUNNER_TEMP/shortlog
Expand All @@ -67,6 +84,7 @@ jobs:
echo "No non-trivial changes; exiting"
exit 0
fi
git checkout $SOURCE_BRANCH
marker=OPENSHIFT-OS-END-OF-LOG-MARKER-$RANDOM$RANDOM$RANDOM
Expand All @@ -77,7 +95,7 @@ jobs:
EOF
- name: Open pull request
uses: peter-evans/create-pull-request@v4.2.3
uses: peter-evans/create-pull-request@v6.0.0
with:
token: ${{ secrets.COREOSBOT_RELENG_TOKEN }}
push-to-fork: coreosbot-releng/os
Expand Down

0 comments on commit 1909aa9

Please sign in to comment.