Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: Push artifacts versions to Network Operator repo #37

Merged
merged 1 commit into from
Jan 2, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 82 additions & 74 deletions .github/workflows/fork-ci.yaml
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
name: Fork Docker CI

# on:
# push:
# branches:
# - network-operator-*
# tags:
# - network-operator-*
on:
push:
branches:
- network-operator-*
tags:
- network-operator-*

jobs:
determine_docker_registry_and_tag:
runs-on: ubuntu-latest
env:
REGISTRY_INTERNAL: nvcr.io/nvstaging/mellanox
REGISTRY_PUBLIC: nvcr.io/nvidia/cloud-native
REGISTRY_PUBLIC: nvcr.io/nvidia/mellanox
steps:
- uses: actions/checkout@v4
with:
sparse-checkout: .
- if: github.ref_type == 'branch'
name: Determine docker registry and tag (when git branch)
run: |
echo DOCKER_REGISTRY=$REGISTRY_INTERNAL >> $GITHUB_ENV
echo DOCKER_TAG=$(git rev-parse --short HEAD) >> $GITHUB_ENV # short git commit hash
- if: github.ref_type == 'tag'
name: Determine docker registry and tag (when git tag)
run: |
echo DOCKER_REGISTRY=$(echo ${{ github.ref_name }} | sed 's/network-operator-//' | grep -q '-' && echo $REGISTRY_INTERNAL || echo $REGISTRY_PUBLIC) >> $GITHUB_ENV # use public registry only when release tag has no '-beta*' or '-rc*' suffix
echo DOCKER_TAG=${{ github.ref_name }} >> $GITHUB_ENV
- name: Store docker registry and tag for following jobs
id: store-docker-registry-and-tag
run: |
echo DOCKER_REGISTRY=$DOCKER_REGISTRY >> $GITHUB_OUTPUT
echo DOCKER_TAG=$DOCKER_TAG >> $GITHUB_OUTPUT
- uses: actions/checkout@v4
with:
sparse-checkout: .
- if: github.ref_type == 'branch'
name: Determine docker registry and tag (when git branch)
run: |
echo DOCKER_REGISTRY=$REGISTRY_INTERNAL >> $GITHUB_ENV
echo DOCKER_TAG=$(git rev-parse --short HEAD) >> $GITHUB_ENV # short git commit hash
- if: github.ref_type == 'tag'
name: Determine docker registry and tag (when git tag)
run: |
echo DOCKER_REGISTRY=$(echo ${{ github.ref_name }} | sed 's/network-operator-//' | grep -q '-' && echo $REGISTRY_INTERNAL || echo $REGISTRY_PUBLIC) >> $GITHUB_ENV # use public registry only when release tag has no '-beta*' or '-rc*' suffix
echo DOCKER_TAG=${{ github.ref_name }} >> $GITHUB_ENV
- name: Store docker registry and tag for following jobs
id: store-docker-registry-and-tag
run: |
echo DOCKER_REGISTRY=$DOCKER_REGISTRY >> $GITHUB_OUTPUT
echo DOCKER_TAG=$DOCKER_TAG >> $GITHUB_OUTPUT
maze88 marked this conversation as resolved.
Show resolved Hide resolved
outputs:
docker_registry: ${{ steps.store-docker-registry-and-tag.outputs.DOCKER_REGISTRY }}
docker_tag: ${{ steps.store-docker-registry-and-tag.outputs.DOCKER_TAG }}
Expand All @@ -46,62 +46,70 @@ jobs:
strategy:
matrix:
include:
- component: operator
image_name: ${{ github.event.repository.name }}
dockerfile: Dockerfile
- component: config-daemon
image_name: ${{ github.event.repository.name }}-config-daemon
dockerfile: Dockerfile.sriov-network-config-daemon
- component: webhook
image_name: ${{ github.event.repository.name }}-webhook
dockerfile: Dockerfile.webhook
- component: operator
image_name: ${{ github.event.repository.name }}
dockerfile: Dockerfile
- component: config-daemon
image_name: ${{ github.event.repository.name }}-config-daemon
dockerfile: Dockerfile.sriov-network-config-daemon
- component: webhook
image_name: ${{ github.event.repository.name }}-webhook
dockerfile: Dockerfile.webhook
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.NVCR_USERNAME }}
password: ${{ secrets.NVCR_TOKEN }}
- uses: docker/build-push-action@v4
with:
platforms: ${{ env.BUILD_PLATFORMS }}
context: .
file: ${{ matrix.dockerfile }}
tags: ${{ env.DOCKER_REGISTRY }}/${{ matrix.image_name }}:${{ env.DOCKER_TAG }}
push: true
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ secrets.NVCR_USERNAME }}
password: ${{ secrets.NVCR_TOKEN }}
- uses: docker/build-push-action@v4
with:
platforms: ${{ env.BUILD_PLATFORMS }}
context: .
file: ${{ matrix.dockerfile }}
tags: ${{ env.DOCKER_REGISTRY }}/${{ matrix.image_name }}:${{ env.DOCKER_TAG }}
push: true

update_network_operator_values:
needs:
- determine_docker_registry_and_tag
- build_and_push_images
- determine_docker_registry_and_tag
- build_and_push_images
runs-on: ubuntu-latest
env:
DOCKER_REGISTRY: ${{ needs.determine_docker_registry_and_tag.outputs.docker_registry }}
DOCKER_TAG: ${{ needs.determine_docker_registry_and_tag.outputs.docker_tag }}
GH_TOKEN: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }}
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }}
repository: ${{ github.repository_owner }}/network-operator
- name: Create PR to update image tags in network-operator values
run: |
git config user.name nvidia-ci-cd
git config user.email [email protected]

git checkout -b feature/update-sriov-tags-to-$DOCKER_TAG
sed -Ei "s/(version: )network-operator-.+/\\1$DOCKER_TAG/g" hack/release.yaml
make release-build
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }}
repository: ${{ github.repository_owner }}/network-operator
maze88 marked this conversation as resolved.
Show resolved Hide resolved
- name: Determine base branch
run: |
echo "BASE_BRANCH=${{ contains(env.DOCKER_TAG, 'beta') && 'master' || env.DOCKER_TAG }}" >> $GITHUB_ENV
- name: Create PR to update image tags in network-operator values
run: |

git config user.name nvidia-ci-cd
git config user.email [email protected]

git checkout -b feature/update-sriov-tags-to-$DOCKER_TAG

cp -r ../sriov-network-operator/deployment/sriov-network-operator-chart/* deployment/network-operator/charts/sriov-network-operator/

yq -i e '.SriovNetworkOperator.repository |= "${{ env.DOCKER_REGISTRY }}"' hack/release.yaml
yq -i e '.SriovNetworkOperator.version |= "${{ env.DOCKER_TAG }}"' hack/release.yaml
Copy link
Member

@rollandf rollandf Dec 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some steps are different from current draft-image-builder.jenkinsfile

  • Need to sync the helm chart
  • When is the Network Operator image built and release.yaml updated with it?
  • When is the Chart.yaml updated?
  • All GA handling (different repositories)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some steps are different from current draft-image-builder.jenkinsfile

  • Need to sync the helm chart
    done
  • When is the Network Operator image built and release.yaml updated with it?
    it will be done in network operator action
  • When is the Chart.yaml updated?
    @rollandf could you please add more details regarding this comment?
  • All GA handling (different repositories)
    done

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding chart.yaml, this is waht we have in draft-image-builder.jenkinsfile

                def chart_file = './deployment/network-operator/Chart.yaml'
                def ChartData = readYaml file: "${chart_file}"

                ChartData.version = "${(version.substring(1))}"
                ChartData.appVersion = "${version}"

                writeYaml file: "${chart_file}", data: ChartData, overwrite: true

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@e0ne I am OK to merge this and iterate on follow ups

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Regarding chart.yaml, this is waht we have in draft-image-builder.jenkinsfile

it should be fixed in package-and-push-helm-chart job or some other which merges code into the repo

make release-build

if ! git diff --color --unified=0 --exit-code; then
git commit -sam "task: update SR-IOV images tags to $DOCKER_TAG in chart values"
git push -u origin feature/update-sriov-tags-to-$DOCKER_TAG
gh pr create \
--repo ${{ github.repository_owner }}/network-operator \
--base master \
--head $(git branch --show-current) \
--fill \
--body "Created by the *${{ github.job }}* job in [${{ github.repository }} CI](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
fi
# TODO: double check with ivan about freddy's question: should we push to master or to a release branch?
if ! git diff --color --unified=0 --exit-code; then
git commit -sam "task: update SR-IOV images tags to $DOCKER_TAG in chart values"
git push -u origin feature/update-sriov-tags-to-$DOCKER_TAG
gh pr create \
--repo ${{ github.repository_owner }}/network-operator \
--base $BASE_BRANCH \
--head $(git branch --show-current) \
--fill \
--body "Created by the *${{ github.job }}* job in [${{ github.repository }} CI](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
fi
Loading