From b185f590e73228b796ef9d378c1866831aa6c6ee Mon Sep 17 00:00:00 2001 From: Harshad Reddy Nalla Date: Fri, 20 Oct 2023 13:59:19 -0400 Subject: [PATCH] Include only sync github workflow on the main branch Signed-off-by: Harshad Reddy Nalla --- .../workflows/auto-add-issue-to-project.yml | 25 --- .../notebooks-digest-updater-upstream.yaml | 165 ------------------ .github/workflows/piplock-renewal-2023a.yml | 47 ----- .github/workflows/piplock-renewal-2023b.yml | 47 ----- .github/workflows/pr-merge-image-delete.yml | 95 ---------- .../workflows/sync-release-branch-2023a.yml | 35 ++++ .../workflows/sync-release-branch-2023b.yml | 35 ++++ 7 files changed, 70 insertions(+), 379 deletions(-) delete mode 100644 .github/workflows/auto-add-issue-to-project.yml delete mode 100644 .github/workflows/notebooks-digest-updater-upstream.yaml delete mode 100644 .github/workflows/piplock-renewal-2023a.yml delete mode 100644 .github/workflows/piplock-renewal-2023b.yml delete mode 100644 .github/workflows/pr-merge-image-delete.yml create mode 100644 .github/workflows/sync-release-branch-2023a.yml create mode 100644 .github/workflows/sync-release-branch-2023b.yml diff --git a/.github/workflows/auto-add-issue-to-project.yml b/.github/workflows/auto-add-issue-to-project.yml deleted file mode 100644 index c222441f3..000000000 --- a/.github/workflows/auto-add-issue-to-project.yml +++ /dev/null @@ -1,25 +0,0 @@ ---- -name: Auto Add Issues to Tracking boards -on: # yamllint disable-line rule:truthy - issues: - types: - - opened -jobs: - add-to-project: - name: Add issue to projects - runs-on: ubuntu-latest - steps: - - name: Generate github-app token - id: app-token - uses: getsentry/action-github-app-token@v2 - with: - app_id: ${{ secrets.DEVOPS_APP_ID }} - private_key: ${{ secrets.DEVOPS_APP_PRIVATE_KEY }} - - uses: actions/add-to-project@v0.5.0 - with: - project-url: https://github.com/orgs/opendatahub-io/projects/40 - github-token: ${{ steps.app-token.outputs.token }} - - uses: actions/add-to-project@v0.5.0 - with: - project-url: https://github.com/orgs/opendatahub-io/projects/45 - github-token: ${{ steps.app-token.outputs.token }} diff --git a/.github/workflows/notebooks-digest-updater-upstream.yaml b/.github/workflows/notebooks-digest-updater-upstream.yaml deleted file mode 100644 index 8d1c6bc84..000000000 --- a/.github/workflows/notebooks-digest-updater-upstream.yaml +++ /dev/null @@ -1,165 +0,0 @@ ---- -# The aim of this GitHub workflow is to update the params.env file with the latest digest. -name: Update notebook image build commit hashes -on: # yamllint disable-line rule:truthy - workflow_dispatch: - inputs: - branch: - required: true - description: "Provide the name of the branch you want to update ex main, vYYYYx etc: " - # Put the scheduler on comment until automate the full release procedure - # schedule: - # - cron: "0 0 * * 5" #Scheduled every Friday -env: - DIGEST_UPDATER_BRANCH: digest-updater-${{ github.run_id }} - BRANCH_NAME: ${{ github.event.inputs.branch || 'main' }} - RELEASE_VERSION_N: 2023b - RELEASE_VERSION_N_1: 2023a -jobs: - initialize: - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Install Skopeo CLI - shell: bash - run: | - sudo apt-get -y update - sudo apt-get -y install skopeo - - # Checkout the branch - - name: Checkout branch - uses: actions/checkout@v3 - with: - ref: ${{ env.BRANCH_NAME }} - - # Create a new branch - - name: Create a new branch - run: | - echo ${{ env.DIGEST_UPDATER_BRANCH }} - git checkout -b ${{ env.DIGEST_UPDATER_BRANCH }} - git push --set-upstream origin ${{ env.DIGEST_UPDATER_BRANCH }} - - update-n-version: - needs: [initialize] - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Configure Git - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "GitHub Actions" - - # Get the latest weekly build commit hash: https://github.com/opendatahub-io/notebooks/commits/2023b - - name: Checkout upstream notebooks repo - uses: actions/checkout@v3 - with: - repository: opendatahub-io/notebooks.git - ref: ${{ env.RELEASE_VERSION_N }} - - - name: Retrieve latest weekly commit hash from the release branch - id: hash-n - shell: bash - run: | - echo "HASH_N=$(git rev-parse --short HEAD)" >> ${GITHUB_OUTPUT} - - # Checkout the release branch to apply the updates - - name: Checkout release branch - uses: actions/checkout@v3 - with: - ref: ${{ env.DIGEST_UPDATER_BRANCH }} - - - name: Fetch digest, and update the param.env file - run: | - echo Latest commit is: ${{ steps.hash-n.outputs.HASH_N }} on ${{ env.RELEASE_VERSION_N}} - IMAGES=("odh-minimal-notebook-image-n" "odh-minimal-gpu-notebook-image-n" "odh-pytorch-gpu-notebook-image-n" "odh-generic-data-science-notebook-image-n" "odh-tensorflow-gpu-notebook-image-n" "odh-trustyai-notebook-image-n") - for ((i=0;i<${#IMAGES[@]};++i)); do - image=${IMAGES[$i]} - echo $image - img=$(cat manifests/base/params.env | grep -E "${image}=" | cut -d '=' -f2) - registry=$(echo $img | cut -d '@' -f1) - src_tag=$(skopeo inspect docker://$img | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//') - regex="$src_tag-${{ env.RELEASE_VERSION_N}}-\d+-${{ steps.hash-n.outputs.HASH_N }}" - latest_tag=$(skopeo inspect docker://$img | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]') - digest=$(skopeo inspect docker://$registry:$latest_tag | jq .Digest | tr -d '"') - output=$registry@$digest - echo $output - sed -i "s|${image}=.*|${image}=$output|" manifests/base/params.env - done - git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && git add manifests/base/params.env && git commit -m "Update images for release N via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && git push origin ${{ env.DIGEST_UPDATER_BRANCH }} - - update-n-1-version: - needs: [initialize, update-n-version] - runs-on: ubuntu-latest - permissions: - contents: write - steps: - - name: Configure Git - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "GitHub Actions" - - # Get the latest weekly build commit hash: https://github.com/opendatahub-io/notebooks/commits/2023a - - name: Checkout upstream notebooks repo - uses: actions/checkout@v3 - with: - repository: opendatahub-io/notebooks.git - ref: ${{ env.RELEASE_VERSION_N_1 }} - - - name: Retrieve latest weekly commit hash from the release branch - id: hash-n-1 - shell: bash - run: | - echo "HASH_N_1=$(git rev-parse --short HEAD)" >> ${GITHUB_OUTPUT} - - # Checkout the release branch to apply the updates - - name: Checkout release branch - uses: actions/checkout@v3 - with: - ref: ${{ env.DIGEST_UPDATER_BRANCH }} - - - name: Fetch digest, and update the param.env file - run: | - echo Latest commit is: ${{ steps.hash-n-1.outputs.HASH_N_1 }} on ${{ env.RELEASE_VERSION_N_1}} - IMAGES=("odh-minimal-notebook-image-n-1" "odh-minimal-gpu-notebook-image-n-1" "odh-pytorch-gpu-notebook-image-n-1" "odh-generic-data-science-notebook-image-n-1" "odh-tensorflow-gpu-notebook-image-n-1" "odh-trustyai-notebook-image-n-1") - for ((i=0;i<${#IMAGES[@]};++i)); do - image=${IMAGES[$i]} - echo $image - img=$(cat manifests/base/params.env | grep -E "${image}=" | cut -d '=' -f2) - registry=$(echo $img | cut -d '@' -f1) - src_tag=$(skopeo inspect docker://$img | jq '.Env[] | select(startswith("OPENSHIFT_BUILD_NAME=")) | split("=")[1]' | tr -d '"' | sed 's/-amd64$//') - regex="$src_tag-${{ env.RELEASE_VERSION_N_1}}-\d+-${{ steps.hash-n-1.outputs.HASH_N_1 }}" - latest_tag=$(skopeo inspect docker://$img | jq -r --arg regex "$regex" '.RepoTags | map(select(. | test($regex))) | .[0]') - digest=$(skopeo inspect docker://$registry:$latest_tag | jq .Digest | tr -d '"') - output=$registry@$digest - echo $output - sed -i "s|${image}=.*|${image}=$output|" manifests/base/params.env - done - git fetch origin ${{ env.DIGEST_UPDATER_BRANCH }} && git pull origin ${{ env.DIGEST_UPDATER_BRANCH }} && git add manifests/base/params.env && git commit -m "Update images for release N-1 via ${{ env.DIGEST_UPDATER_BRANCH }} GitHub action" && git push origin ${{ env.DIGEST_UPDATER_BRANCH }} - - # Creates the Pull Request - open-pull-request: - needs: [update-n-version, update-n-1-version] - runs-on: ubuntu-latest - permissions: - pull-requests: write - steps: - - name: Checkout repo - uses: actions/checkout@v3 - - - name: pull-request - uses: repo-sync/pull-request@v2 - with: - source_branch: ${{ env.DIGEST_UPDATER_BRANCH }} - destination_branch: ${{ env.BRANCH_NAME}} - github_token: ${{ secrets.GITHUB_TOKEN }} - pr_label: "automated pr" - pr_title: "[Digest Updater Action] Update notebook's imageStreams image tag to digest format" - pr_body: | - :rocket: This is an automated Pull Request. - - This PR updates the `manifests/base/params.env` file with the latest updated SHA digests of the notebooks (N & N-1). - Created by `/.github/workflows/notebooks-digest-updater-upstream.yaml` - - :exclamation: **IMPORTANT NOTE**: Remember to delete the ` ${{ env.DIGEST_UPDATER_BRANCH }}` branch after merging the changes diff --git a/.github/workflows/piplock-renewal-2023a.yml b/.github/workflows/piplock-renewal-2023a.yml deleted file mode 100644 index 4f17147b8..000000000 --- a/.github/workflows/piplock-renewal-2023a.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This GitHub action is meant to be triggered weekly in order to update the pipfile.locks - -name: Weekly Pipfile.locks renewal on [2023a] branch - -on: # yamllint disable-line rule:truthy - # Triggers the workflow every Monday at 22pm UTC am 0 22 * * 1 - schedule: - - cron: "0 22 * * 1" - workflow_dispatch: # for manual trigger workflow from GH Web UI - -jobs: - build: - runs-on: ubuntu-latest - - permissions: - # Give the default GITHUB_TOKEN write permission to commit and push the - # added or changed files to the repository. - contents: write - - steps: - # Checkout the paricular branch - - name: Checkout code from the release branch - uses: actions/checkout@v3 - with: - ref: 2023a - token: ${{ secrets.GH_ACCESS_TOKEN }} - - # Setup Python environment - - name: Setup Python environment - uses: actions/setup-python@v4 - with: - python-version: | - 3.8 - 3.9 - - name: Install pipenv - run: pip install pipenv - - # Runs the makefile recipe `refresh-pipfilelock-files` and push the chances back to the branch - - name: Run make refresh-pipfilelock-files and push the chances back to the branch - run: | - make refresh-pipfilelock-files - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "GitHub Actions" - git add . - git commit -m "Update the pipfile.lock via the weekly workflow action" - git push diff --git a/.github/workflows/piplock-renewal-2023b.yml b/.github/workflows/piplock-renewal-2023b.yml deleted file mode 100644 index 6ea54fa8c..000000000 --- a/.github/workflows/piplock-renewal-2023b.yml +++ /dev/null @@ -1,47 +0,0 @@ ---- -# This GitHub action is meant to be triggered weekly in order to update the pipfile.locks - -name: Weekly Pipfile.locks renewal on [2023b] branch - -on: # yamllint disable-line rule:truthy - # Triggers the workflow every Monday at 22pm UTC am 0 22 * * 1 - schedule: - - cron: "0 22 * * 1" - workflow_dispatch: # for manual trigger workflow from GH Web UI - -jobs: - build: - runs-on: ubuntu-latest - - permissions: - # Give the default GITHUB_TOKEN write permission to commit and push the - # added or changed files to the repository. - contents: write - - steps: - # Checkout the paricular branch - - name: Checkout code from the release branch - uses: actions/checkout@v3 - with: - ref: 2023b - token: ${{ secrets.GH_ACCESS_TOKEN }} - - # Setup Python environment - - name: Setup Python environment - uses: actions/setup-python@v4 - with: - python-version: | - 3.8 - 3.9 - - name: Install pipenv - run: pip install pipenv - - # Runs the makefile recipe `refresh-pipfilelock-files` and push the chances back to the branch - - name: Run make refresh-pipfilelock-files and push the chances back to the branch - run: | - make refresh-pipfilelock-files - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "GitHub Actions" - git add . - git commit -m "Update the pipfile.lock via the weekly workflow action" - git push diff --git a/.github/workflows/pr-merge-image-delete.yml b/.github/workflows/pr-merge-image-delete.yml deleted file mode 100644 index 41da2aabb..000000000 --- a/.github/workflows/pr-merge-image-delete.yml +++ /dev/null @@ -1,95 +0,0 @@ ---- -name: Delete quay image of PR once merged -on: # yamllint disable-line rule:truthy - push: - branches: - - 'main' - -permissions: - pull-requests: read -env: - QUAY_IMAGE_REPO: ${{ secrets.QUAY_IMAGE_REPO }} -jobs: - delete-pr-quay-image: - runs-on: ubuntu-latest - steps: - - name: Git checkout - uses: actions/checkout@v3 - with: - fetch-depth: '0' - - name: Install skopeo - shell: bash - run: | - sudo apt-get -y update - sudo apt-get -y install skopeo - - name: Get Pull Request Number - uses: actions/github-script@v6 - id: get_pr_number - with: - script: | - if (context.issue.number) { - // Return issue number if present - return context.issue.number; - } else { - // Otherwise return issue number from commit - return ( - await github.rest.repos.listPullRequestsAssociatedWithCommit({ - commit_sha: context.sha, - owner: context.repo.owner, - repo: context.repo.repo, - }) - ).data[0].number; - } - result-encoding: string - env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} - - name: Login to quay.io - shell: bash - env: - QUAY_ROBOT_USERNAME: ${{ secrets.QUAY_ROBOT_USERNAME }} - QUAY_ROBOT_TOKEN: ${{ secrets.QUAY_ROBOT_TOKEN }} - run: | - skopeo login quay.io -u ${QUAY_ROBOT_USERNAME} -p ${QUAY_ROBOT_TOKEN} - - name: Delete PR image - shell: bash - continue-on-error: true - env: - PR: ${{steps.get_pr_number.outputs.result}} - run: | - - set +e # Don't abort if a delete operation fails as all images might not be available for the PR - - skopeo delete docker://${QUAY_IMAGE_REPO}:base-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:base-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:base-c9s-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:cuda-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:cuda-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:cuda-c9s-python-3.9-pr-${{ env.PR }} - - skopeo delete docker://${QUAY_IMAGE_REPO}:jupyter-minimal-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:jupyter-datascience-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:jupyter-pytorch-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:jupyter-trustyai-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:jupyter-datascience-anaconda-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:cuda-jupyter-minimal-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:cuda-jupyter-datascience-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:cuda-jupyter-tensorflow-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:runtime-minimal-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:runtime-datascience-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:runtime-pytorch-ubi8-python-3.8-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:runtime-cuda-tensorflow-ubi8-python-3.8-pr-${{ env.PR }} - - skopeo delete docker://${QUAY_IMAGE_REPO}:jupyter-minimal-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:jupyter-datascience-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:jupyter-pytorch-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:jupyter-trustyai-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:cuda-jupyter-minimal-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:cuda-jupyter-datascience-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:cuda-jupyter-tensorflow-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:runtime-minimal-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:runtime-datascience-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:runtime-pytorch-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:runtime-cuda-tensorflow-ubi9-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:codeserver-c9s-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:rstudio-c9s-python-3.9-pr-${{ env.PR }} - skopeo delete docker://${QUAY_IMAGE_REPO}:cuda-rstudio-c9s-python-3.9-pr-${{ env.PR }} diff --git a/.github/workflows/sync-release-branch-2023a.yml b/.github/workflows/sync-release-branch-2023a.yml new file mode 100644 index 000000000..df5f89398 --- /dev/null +++ b/.github/workflows/sync-release-branch-2023a.yml @@ -0,0 +1,35 @@ +# This GitHub action is meant to be triggered weekly in order to sync the upstream release branch with the downstream branch fork + +name: Sync downstream release-2023a branch with upstream's +on: + # Triggers the workflow every Tue at 8 A.M + schedule: + - cron: "0 8 * * 2" + workflow_dispatch: # for manual trigger workflow from GH Web UI +env: + # UPSTREAM_URL: "https://github.com/opendatahub-io/notebooks.git" + UPSTREAM_REPO: "opendatahub-io/notebooks" + UPSTREAM_BRANCH: "2023a" + DOWNSTREAM_BRANCH: "release-2023a" +jobs: + sync_latest_from_upstream: + runs-on: ubuntu-latest + # Bug in GitHub Action does not support env variable in name + name: sync release branch from 2023a to release-2023a + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + ref: ${{ env.DOWNSTREAM_BRANCH }} + - name: Sync upstream changes + id: sync + uses: aormsby/Fork-Sync-With-Upstream-action@v3.4 + with: + target_sync_branch: ${{ env.DOWNSTREAM_BRANCH }} + target_repo_token: ${{ secrets.GITHUB_TOKEN }} + upstream_sync_branch: ${{ env.UPSTREAM_BRANCH }} + upstream_sync_repo: ${{ env.UPSTREAM_REPO }} + - name: New commits found + if: steps.sync.outputs.has_new_commits == 'true' + run: echo "New commits were found to sync." + diff --git a/.github/workflows/sync-release-branch-2023b.yml b/.github/workflows/sync-release-branch-2023b.yml new file mode 100644 index 000000000..29e6bab99 --- /dev/null +++ b/.github/workflows/sync-release-branch-2023b.yml @@ -0,0 +1,35 @@ +# This GitHub action is meant to be triggered weekly in order to sync the upstream release branch with the downstream branch fork + +name: Sync downstream release-2023b branch with upstream's +on: + # Triggers the workflow every Tue at 8 A.M + schedule: + - cron: "0 8 * * 2" + workflow_dispatch: # for manual trigger workflow from GH Web UI +env: + # UPSTREAM_URL: "https://github.com/opendatahub-io/notebooks.git" + UPSTREAM_REPO: "opendatahub-io/notebooks" + UPSTREAM_BRANCH: "2023b" + DOWNSTREAM_BRANCH: "release-2023b" +jobs: + sync_latest_from_upstream: + runs-on: ubuntu-latest + # Bug in GitHub Action does not support env variable in name + name: sync release branch from 2023b to release-2023b + steps: + - name: Checkout repo + uses: actions/checkout@v3 + with: + ref: ${{ env.DOWNSTREAM_BRANCH }} + - name: Sync upstream changes + id: sync + uses: aormsby/Fork-Sync-With-Upstream-action@v3.4 + with: + target_sync_branch: ${{ env.DOWNSTREAM_BRANCH }} + target_repo_token: ${{ secrets.GITHUB_TOKEN }} + upstream_sync_branch: ${{ env.UPSTREAM_BRANCH }} + upstream_sync_repo: ${{ env.UPSTREAM_REPO }} + - name: New commits found + if: steps.sync.outputs.has_new_commits == 'true' + run: echo "New commits were found to sync." +