Skip to content

Commit 5985e27

Browse files
authored
Merge pull request #37 from e0ne/fork-ci
ci: Push artifacts versions to Network Operator repo
2 parents ff12733 + 46878e1 commit 5985e27

File tree

1 file changed

+82
-74
lines changed

1 file changed

+82
-74
lines changed

.github/workflows/fork-ci.yaml

Lines changed: 82 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,37 @@
11
name: Fork Docker CI
22

3-
# on:
4-
# push:
5-
# branches:
6-
# - network-operator-*
7-
# tags:
8-
# - network-operator-*
3+
on:
4+
push:
5+
branches:
6+
- network-operator-*
7+
tags:
8+
- network-operator-*
99

1010
jobs:
1111
determine_docker_registry_and_tag:
1212
runs-on: ubuntu-latest
1313
env:
1414
REGISTRY_INTERNAL: nvcr.io/nvstaging/mellanox
15-
REGISTRY_PUBLIC: nvcr.io/nvidia/cloud-native
15+
REGISTRY_PUBLIC: nvcr.io/nvidia/mellanox
1616
steps:
17-
- uses: actions/checkout@v4
18-
with:
19-
sparse-checkout: .
20-
- if: github.ref_type == 'branch'
21-
name: Determine docker registry and tag (when git branch)
22-
run: |
23-
echo DOCKER_REGISTRY=$REGISTRY_INTERNAL >> $GITHUB_ENV
24-
echo DOCKER_TAG=$(git rev-parse --short HEAD) >> $GITHUB_ENV # short git commit hash
25-
- if: github.ref_type == 'tag'
26-
name: Determine docker registry and tag (when git tag)
27-
run: |
28-
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
29-
echo DOCKER_TAG=${{ github.ref_name }} >> $GITHUB_ENV
30-
- name: Store docker registry and tag for following jobs
31-
id: store-docker-registry-and-tag
32-
run: |
33-
echo DOCKER_REGISTRY=$DOCKER_REGISTRY >> $GITHUB_OUTPUT
34-
echo DOCKER_TAG=$DOCKER_TAG >> $GITHUB_OUTPUT
17+
- uses: actions/checkout@v4
18+
with:
19+
sparse-checkout: .
20+
- if: github.ref_type == 'branch'
21+
name: Determine docker registry and tag (when git branch)
22+
run: |
23+
echo DOCKER_REGISTRY=$REGISTRY_INTERNAL >> $GITHUB_ENV
24+
echo DOCKER_TAG=$(git rev-parse --short HEAD) >> $GITHUB_ENV # short git commit hash
25+
- if: github.ref_type == 'tag'
26+
name: Determine docker registry and tag (when git tag)
27+
run: |
28+
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
29+
echo DOCKER_TAG=${{ github.ref_name }} >> $GITHUB_ENV
30+
- name: Store docker registry and tag for following jobs
31+
id: store-docker-registry-and-tag
32+
run: |
33+
echo DOCKER_REGISTRY=$DOCKER_REGISTRY >> $GITHUB_OUTPUT
34+
echo DOCKER_TAG=$DOCKER_TAG >> $GITHUB_OUTPUT
3535
outputs:
3636
docker_registry: ${{ steps.store-docker-registry-and-tag.outputs.DOCKER_REGISTRY }}
3737
docker_tag: ${{ steps.store-docker-registry-and-tag.outputs.DOCKER_TAG }}
@@ -46,62 +46,70 @@ jobs:
4646
strategy:
4747
matrix:
4848
include:
49-
- component: operator
50-
image_name: ${{ github.event.repository.name }}
51-
dockerfile: Dockerfile
52-
- component: config-daemon
53-
image_name: ${{ github.event.repository.name }}-config-daemon
54-
dockerfile: Dockerfile.sriov-network-config-daemon
55-
- component: webhook
56-
image_name: ${{ github.event.repository.name }}-webhook
57-
dockerfile: Dockerfile.webhook
49+
- component: operator
50+
image_name: ${{ github.event.repository.name }}
51+
dockerfile: Dockerfile
52+
- component: config-daemon
53+
image_name: ${{ github.event.repository.name }}-config-daemon
54+
dockerfile: Dockerfile.sriov-network-config-daemon
55+
- component: webhook
56+
image_name: ${{ github.event.repository.name }}-webhook
57+
dockerfile: Dockerfile.webhook
5858
steps:
59-
- uses: actions/checkout@v4
60-
- uses: docker/setup-qemu-action@v3
61-
- uses: docker/setup-buildx-action@v3
62-
- uses: docker/login-action@v3
63-
with:
64-
registry: ${{ env.DOCKER_REGISTRY }}
65-
username: ${{ secrets.NVCR_USERNAME }}
66-
password: ${{ secrets.NVCR_TOKEN }}
67-
- uses: docker/build-push-action@v4
68-
with:
69-
platforms: ${{ env.BUILD_PLATFORMS }}
70-
context: .
71-
file: ${{ matrix.dockerfile }}
72-
tags: ${{ env.DOCKER_REGISTRY }}/${{ matrix.image_name }}:${{ env.DOCKER_TAG }}
73-
push: true
59+
- uses: actions/checkout@v4
60+
- uses: docker/setup-qemu-action@v3
61+
- uses: docker/setup-buildx-action@v3
62+
- uses: docker/login-action@v3
63+
with:
64+
registry: ${{ env.DOCKER_REGISTRY }}
65+
username: ${{ secrets.NVCR_USERNAME }}
66+
password: ${{ secrets.NVCR_TOKEN }}
67+
- uses: docker/build-push-action@v4
68+
with:
69+
platforms: ${{ env.BUILD_PLATFORMS }}
70+
context: .
71+
file: ${{ matrix.dockerfile }}
72+
tags: ${{ env.DOCKER_REGISTRY }}/${{ matrix.image_name }}:${{ env.DOCKER_TAG }}
73+
push: true
7474

7575
update_network_operator_values:
7676
needs:
77-
- determine_docker_registry_and_tag
78-
- build_and_push_images
77+
- determine_docker_registry_and_tag
78+
- build_and_push_images
7979
runs-on: ubuntu-latest
8080
env:
81+
DOCKER_REGISTRY: ${{ needs.determine_docker_registry_and_tag.outputs.docker_registry }}
8182
DOCKER_TAG: ${{ needs.determine_docker_registry_and_tag.outputs.docker_tag }}
8283
GH_TOKEN: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }}
8384
steps:
84-
- uses: actions/checkout@v4
85-
with:
86-
token: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }}
87-
repository: ${{ github.repository_owner }}/network-operator
88-
- name: Create PR to update image tags in network-operator values
89-
run: |
90-
git config user.name nvidia-ci-cd
91-
git config user.email svc-cloud-orch-gh@nvidia.com
92-
93-
git checkout -b feature/update-sriov-tags-to-$DOCKER_TAG
94-
sed -Ei "s/(version: )network-operator-.+/\\1$DOCKER_TAG/g" hack/release.yaml
95-
make release-build
85+
- uses: actions/checkout@v4
86+
with:
87+
token: ${{ secrets.GH_TOKEN_NVIDIA_CI_CD }}
88+
repository: ${{ github.repository_owner }}/network-operator
89+
- name: Determine base branch
90+
run: |
91+
echo "BASE_BRANCH=${{ contains(env.DOCKER_TAG, 'beta') && 'master' || env.DOCKER_TAG }}" >> $GITHUB_ENV
92+
- name: Create PR to update image tags in network-operator values
93+
run: |
94+
95+
git config user.name nvidia-ci-cd
96+
git config user.email svc-cloud-orch-gh@nvidia.com
97+
98+
git checkout -b feature/update-sriov-tags-to-$DOCKER_TAG
99+
100+
cp -r ../sriov-network-operator/deployment/sriov-network-operator-chart/* deployment/network-operator/charts/sriov-network-operator/
101+
102+
yq -i e '.SriovNetworkOperator.repository |= "${{ env.DOCKER_REGISTRY }}"' hack/release.yaml
103+
yq -i e '.SriovNetworkOperator.version |= "${{ env.DOCKER_TAG }}"' hack/release.yaml
104+
make release-build
96105
97-
if ! git diff --color --unified=0 --exit-code; then
98-
git commit -sam "task: update SR-IOV images tags to $DOCKER_TAG in chart values"
99-
git push -u origin feature/update-sriov-tags-to-$DOCKER_TAG
100-
gh pr create \
101-
--repo ${{ github.repository_owner }}/network-operator \
102-
--base master \
103-
--head $(git branch --show-current) \
104-
--fill \
105-
--body "Created by the *${{ github.job }}* job in [${{ github.repository }} CI](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
106-
fi
107-
# TODO: double check with ivan about freddy's question: should we push to master or to a release branch?
106+
if ! git diff --color --unified=0 --exit-code; then
107+
git commit -sam "task: update SR-IOV images tags to $DOCKER_TAG in chart values"
108+
git push -u origin feature/update-sriov-tags-to-$DOCKER_TAG
109+
gh pr create \
110+
--repo ${{ github.repository_owner }}/network-operator \
111+
--base $BASE_BRANCH \
112+
--head $(git branch --show-current) \
113+
--fill \
114+
--body "Created by the *${{ github.job }}* job in [${{ github.repository }} CI](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})."
115+
fi

0 commit comments

Comments
 (0)