Skip to content

update-sources-next #37

update-sources-next

update-sources-next #37

# Generated by openshift-pipelines/hack. DO NOT EDIT.
name: update-sources-next
on:
workflow_dispatch: {}
schedule:
- cron: "30 */12 * * *" # At minute 30 past every 12th hour.
jobs:
update-sources:
runs-on: ubuntu-latest
if: github.repository_owner == 'openshift-pipelines' # do not run this elsewhere
permissions:
contents: write
pull-requests: write
steps:
- name: Checkout the current repo
uses: actions/checkout@v4
with:
ref: next
- name: Clone tektoncd/operator
run: |
rm -fR upstream
git clone https://github.com/tektoncd/operator upstream
pushd upstream
git checkout -B main origin/main
popd
- name: fetch-payload
run: |
if [[ -z $(git status --porcelain --untracked-files=no) ]]; then
echo "No change, do nothing"
exit 0
fi
# Operator SDK
export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.37.0/operator-sdk_linux_amd64
curl -LO ${OPERATOR_SDK_DL_URL}
chmod +x operator-sdk_linux_amd64 && sudo mv operator-sdk_linux_amd64 /usr/local/bin/operator-sdk
operator-sdk version
# Python with requirements (yaml here)
# We could migrate to go...
python3 -m venv sync-sources
source sync-sources/bin/activate
pip3 install -r requirements.txt
# Update operator's payload and stuff
make update-payload-and-version
pushd upstream
rm -fR cmd/openshift/operator/kodata operatorhub
git checkout HEAD .
popd
- name: Commit new changes
run: |
git config user.name openshift-pipelines-bot
git config user.email [email protected]
git checkout -b actions/update/sources-next
pushd upstream
OLD_COMMIT=$(cat ../head)
NEW_COMMIT=$(git rev-parse HEAD)
echo Previous commit: ${OLD_COMMIT}
git show --stat ${OLD_COMMIT}
echo New commit: ${NEW_COMMIT}
git show --stat ${NEW_COMMIT}
git diff --stat ${NEW_COMMIT}..${OLD_COMMIT} > /tmp/diff.txt
git rev-parse HEAD > ../head
popd
rm -rf upstream/.git
git add upstream head .konflux
if [[ -z $(git status --porcelain --untracked-files=no) ]]; then
echo "No change, exiting"
exit 0
fi
git commit -F- <<EOF
[bot] Update next from tektoncd/operator to ${NEW_COMMIT}
$ git diff --stat ${NEW_COMMIT}..${OLD_COMMIT}
$(cat /tmp/diff.txt | sed 's/^/ /')
https://github.com/tektoncd/operator/compare/${NEW_COMMIT}..${OLD_COMMIT}
EOF
git push -f origin actions/update/sources-next
if [ "$(gh pr list --base next --head actions/update/sources-next --json url --jq 'length')" = "0" ]; then
echo "creating PR..."
gh pr create -B next -H actions/update/sources-next --label=automated --label=upstream --fill
else
echo "a PR already exists, editing..."
gh pr edit --title "[bot] Update next from tektoncd/operator to ${NEW_COMMIT}" --body "$(cat /tmp/diff.txt | sed 's/^/ /')"
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}