|
| 1 | +name: odh-manifests sync |
| 2 | + |
| 3 | +run-name: Sync manifests in odh-manifests |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + push: |
| 7 | + tags: |
| 8 | + - '*' |
| 9 | +jobs: |
| 10 | + send-pull-requests: |
| 11 | + runs-on: ubuntu-latest |
| 12 | + permissions: |
| 13 | + pull-requests: write |
| 14 | + steps: |
| 15 | + - name: Checkout data-science-pipelines-operator repository |
| 16 | + uses: actions/checkout@v2 |
| 17 | + with: |
| 18 | + fetch-depth: 0 |
| 19 | + ref: main |
| 20 | + repository: opendatahub-io/data-science-pipelines-operator |
| 21 | + token: ${{ secrets.GITHUB_TOKEN }} |
| 22 | + |
| 23 | + - name: Send pull-request |
| 24 | + run: | |
| 25 | + LATEST_TAG=$(git describe --tags --always --abbrev=0) |
| 26 | + REPOSITORY="opendatahub-io/odh-manifests" |
| 27 | + FOLDER="bin/$REPOSITORY" |
| 28 | + BRANCH_NAME="chore-update-scripts-to-$LATEST_TAG" |
| 29 | +
|
| 30 | + # Clone the remote repository and change working directory to the |
| 31 | + # folder it was cloned to. |
| 32 | + git clone \ |
| 33 | + --depth=1 \ |
| 34 | + --branch=master \ |
| 35 | + https://opendatahub-io:${{ secrets.ACCESS_TOKEN }}@github.com/$REPOSITORY \ |
| 36 | + $FOLDER |
| 37 | + cd $FOLDER |
| 38 | +
|
| 39 | + # Setup the committers identity. |
| 40 | + git config user.email "[email protected]" |
| 41 | + git config user.name "dsp-developers" |
| 42 | +
|
| 43 | + # Create a new feature branch for the changes. |
| 44 | + git checkout -b $BRANCH_NAME |
| 45 | + echo "Created branch: $BRANCH_NAME" |
| 46 | +
|
| 47 | + # Copy DSPO manifests. Using rsync to allow filtering of paths/files (e.g. like a .gitignore, hidden files, etc) |
| 48 | +
|
| 49 | + rsync -av --exclude={'overlays/','samples/','internal/'} ../../../config/ data-science-pipelines-operator/ |
| 50 | +
|
| 51 | + # Commit the changes and push the feature branch to origin |
| 52 | + git add . |
| 53 | + git commit -m "Update DSPO to $LATEST_TAG" |
| 54 | + # Check if the branch exists and perform rebase if it does |
| 55 | + if git ls-remote --exit-code --heads origin $BRANCH_NAME; then |
| 56 | + git pull --rebase origin $BRANCH_NAME |
| 57 | + fi |
| 58 | + git push origin $BRANCH_NAME |
| 59 | +
|
| 60 | + gh pr create \ |
| 61 | + --body "This is an automated PR to update Data Science Pipelines Operator manifests to $LATEST_TAG" \ |
| 62 | + --title "Update DSP Operator manifests to $LATEST_TAG" \ |
| 63 | + --head "$BRANCH_NAME" \ |
| 64 | + --base "master" |
| 65 | + env: |
| 66 | + GH_TOKEN: ${{ secrets.ACCESS_TOKEN }} |
0 commit comments