|
| 1 | +# Generated for Konflux Application openshift-pipelines-core by openshift-pipelines/hack. DO NOT EDIT |
| 2 | +name: update-sources |
| 3 | +on: |
| 4 | + workflow_dispatch: {} |
| 5 | + push: |
| 6 | + branches: |
| 7 | + - release-v1.20.x |
| 8 | + paths: |
| 9 | + - .github/workflows/update-sources.yaml |
| 10 | +jobs: |
| 11 | + update-sources: |
| 12 | + runs-on: ubuntu-latest |
| 13 | + permissions: |
| 14 | + contents: write |
| 15 | + pull-requests: write |
| 16 | + steps: |
| 17 | + - name: Checkout the current repo |
| 18 | + uses: actions/checkout@v4 |
| 19 | + with: |
| 20 | + ref: release-v1.20.x |
| 21 | + |
| 22 | + - name: Clone tektoncd/operator |
| 23 | + run: | |
| 24 | + rm -fR upstream |
| 25 | + git clone https://github.com/tektoncd/operator upstream |
| 26 | + pushd upstream |
| 27 | + git checkout -B release-v1.20.x origin/release-v1.20.x |
| 28 | + popd |
| 29 | + - name: fetch-payload |
| 30 | + run: | |
| 31 | + pushd upstream |
| 32 | + BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD) |
| 33 | + popd |
| 34 | + |
| 35 | + if [[ "$BRANCH_NAME" != "main" ]] && [[ -z $(git status --porcelain --untracked-files=no) ]]; then |
| 36 | + echo "No change, do nothing" |
| 37 | + # exit 0 |
| 38 | + fi |
| 39 | + # Operator SDK |
| 40 | + export OPERATOR_SDK_DL_URL=https://github.com/operator-framework/operator-sdk/releases/download/v1.37.0/operator-sdk_linux_amd64 |
| 41 | + curl -LO ${OPERATOR_SDK_DL_URL} |
| 42 | + chmod +x operator-sdk_linux_amd64 && sudo mv operator-sdk_linux_amd64 /usr/local/bin/operator-sdk |
| 43 | + |
| 44 | + operator-sdk version |
| 45 | + |
| 46 | + # Python with requirements (yaml here) |
| 47 | + # We could migrate to go... |
| 48 | + python3 -m venv sync-sources |
| 49 | + source sync-sources/bin/activate |
| 50 | + pip3 install -r requirements.txt |
| 51 | + |
| 52 | + # Update operator's payload and stuff |
| 53 | + make update-payload-and-reference |
| 54 | + pushd upstream |
| 55 | + rm -fR cmd/openshift/operator/kodata operatorhub |
| 56 | + git checkout HEAD . |
| 57 | + popd |
| 58 | + |
| 59 | + - name: Commit new changes |
| 60 | + run: | |
| 61 | + |
| 62 | + set -x |
| 63 | + |
| 64 | + git config user.name openshift-pipelines-bot |
| 65 | + git config user.email pipelines-extcomm@redhat.com |
| 66 | + git checkout -b actions/update/sources-release-v1.20.x |
| 67 | + touch head |
| 68 | + pushd upstream |
| 69 | + OLD_COMMIT=$(cat ../head) |
| 70 | + NEW_COMMIT=$(git rev-parse HEAD) |
| 71 | + echo Previous commit: ${OLD_COMMIT} |
| 72 | + git show --stat ${OLD_COMMIT} |
| 73 | + echo New commit: ${NEW_COMMIT} |
| 74 | + git show --stat ${NEW_COMMIT} |
| 75 | + git diff --stat ${NEW_COMMIT}..${OLD_COMMIT} > /tmp/diff.txt |
| 76 | + git rev-parse HEAD > ../head |
| 77 | + popd |
| 78 | + rm -rf upstream/.git |
| 79 | + git add -f upstream head .konflux |
| 80 | + git add project.yaml |
| 81 | +
|
| 82 | + if [[ -z $(git status --porcelain --untracked-files=no) ]]; then |
| 83 | + echo "No change, exiting" |
| 84 | + exit 0 |
| 85 | + fi |
| 86 | +
|
| 87 | + git commit -F- <<EOF |
| 88 | + [bot] Update release-v1.20.x from tektoncd/operator to ${NEW_COMMIT} |
| 89 | +
|
| 90 | + $ git diff --stat ${NEW_COMMIT}..${OLD_COMMIT} |
| 91 | + $(cat /tmp/diff.txt | sed 's/^/ /' | head -c 55555) |
| 92 | + |
| 93 | + https://github.com/tektoncd/operator/compare/${NEW_COMMIT}..${OLD_COMMIT} |
| 94 | + EOF |
| 95 | + |
| 96 | + git push -f origin actions/update/sources-release-v1.20.x |
| 97 | +
|
| 98 | + if [ "$(gh pr list --base release-v1.20.x --head actions/update/sources-release-v1.20.x --json url --jq 'length')" = "0" ]; then |
| 99 | + echo "creating PR..." |
| 100 | + gh pr create -B release-v1.20.x -H actions/update/sources-release-v1.20.x --label=automated --label=upstream --fill |
| 101 | + else |
| 102 | + echo "a PR already exists, editing..." |
| 103 | + gh pr edit --title "[bot] Update release-v1.20.x from tektoncd/operator to ${NEW_COMMIT}" --body "$(cat /tmp/diff.txt | sed 's/^/ /' | head -c 55555)" |
| 104 | + fi |
| 105 | + env: |
| 106 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments