Skip to content

Commit 8457184

Browse files
authored
Automating upload to registries (#95)
1 parent b29c321 commit 8457184

File tree

1 file changed

+92
-0
lines changed

1 file changed

+92
-0
lines changed
Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
# Implicit requirements
2+
# runner must have `docker` and `curl` installed (true on github-runners)
3+
4+
name: upload-artifacts
5+
# on:
6+
# push:
7+
# branches:
8+
# - master
9+
# pull_request:
10+
# workflow_dispatch:
11+
on:
12+
pull_request:
13+
types:
14+
- closed
15+
jobs:
16+
upload-artifacts:
17+
if: github.event.pull_request.merged
18+
runs-on: ubuntu-latest
19+
steps:
20+
- uses: actions/checkout@v2
21+
- name: install-dependencies
22+
run: |
23+
HELM_PKG="helm-v3.10.3-linux-amd64.tar.gz"
24+
curl -LO https://get.helm.sh/"${HELM_PKG}"
25+
tar -zxvf "${HELM_PKG}"
26+
mv ./linux-amd64/helm .
27+
echo "$(pwd)" >> $GITHUB_PATH
28+
- name: install-aws-cli
29+
uses: unfor19/install-aws-cli-action@v1
30+
with:
31+
version: 2
32+
- name: initialize-aws-cli
33+
run: |
34+
aws configure set aws_access_key_id ${{ secrets.CI_PUBLIC_HELM_S3_KEY_IDENTIFIER }}
35+
aws configure set aws_secret_access_key ${{ secrets.CI_PUBLIC_HELM_S3_KEY_CONTENT }}
36+
aws configure set region "ru-central1"
37+
- name: install-yc
38+
run: |
39+
curl -sSL https://storage.yandexcloud.net/yandexcloud-yc/install.sh | bash
40+
echo "~/yandex-cloud/bin/" >> $GITHUB_PATH
41+
- name: initialize-yc-cli
42+
run: |
43+
# Cloud: yc-ydbaas; catalogue: docker-images
44+
# Cloud: ycr-public-registries; catalogue: cloud-public-images
45+
#
46+
# Service account has access rights in TWO clouds;
47+
# they are synced internally through `iam-sync-configs` repo
48+
yc config profile create private-docker-helm-public-docker
49+
echo "$SA_KEYS_FOR_PRIVATE_DOCKER_HELM_AND_PUBLIC_DOCKER" > sa-key.json
50+
yc config --profile private-docker-helm-public-docker set service-account-key sa-key.json
51+
env:
52+
SA_KEYS_FOR_PRIVATE_DOCKER_HELM_AND_PUBLIC_DOCKER: ${{ secrets.SA_KEYS_FOR_PRIVATE_DOCKER_HELM_AND_PUBLIC_DOCKER }}
53+
- name: parse-version-from-chart
54+
run: |
55+
VERSION=$(cat ./deploy/ydb-operator/Chart.yaml | sed -n 's/^version: //p')
56+
echo "VERSION=$VERSION" >> $GITHUB_ENV
57+
- name: login-to-registries
58+
run: |
59+
cat sa-key.json | docker login --username json_key --password-stdin cr.yandex
60+
yc --profile private-docker-helm-public-docker iam create-token | helm registry login cr.yandex/crpl7ipeu79oseqhcgn2/charts -u iam --password-stdin
61+
- name: build-and-push-operator-image
62+
run: |
63+
# Public:
64+
docker build -t cr.yandex/crpl7ipeu79oseqhcgn2/ydb-operator:"$VERSION" .
65+
docker push cr.yandex/crpl7ipeu79oseqhcgn2/ydb-operator:"$VERSION"
66+
# Private:
67+
# no rebuild will happen, docker will fetch from cache and just retag:
68+
docker build -t cr.yandex/crpsjg1coh47p81vh2lc/ydb-kubernetes-operator:"$VERSION" .
69+
docker push cr.yandex/crpsjg1coh47p81vh2lc/ydb-kubernetes-operator:"$VERSION"
70+
- name: package-and-push-helm-chart
71+
run: |
72+
helm package ./deploy/ydb-operator
73+
74+
# Push into internal oci-based registry
75+
helm push ./ydb-operator-"$VERSION".tgz oci://cr.yandex/crpl7ipeu79oseqhcgn2/charts
76+
77+
# Push into public s3-based registry
78+
aws s3 --endpoint-url=https://storage.yandexcloud.net \
79+
cp ./ydb-operator-"$VERSION".tgz s3://charts.ydb.tech/ydb-operator-"$VERSION".tgz
80+
81+
# Make sure that latest version is available in `helm repo search` later
82+
mkdir charts
83+
cp ./ydb-operator-"$VERSION".tgz ./charts
84+
85+
# Grab an old index, merge current chart into it, and upload back
86+
aws --endpoint-url=https://storage.yandexcloud.net \
87+
s3 cp s3://charts.ydb.tech/index.yaml ./old-index.yaml
88+
89+
helm repo index charts --merge ./old-index.yaml --url https://charts.ydb.tech
90+
91+
aws s3 --endpoint-url=https://storage.yandexcloud.net \
92+
cp ./charts/index.yaml s3://charts.ydb.tech/index.yaml

0 commit comments

Comments
 (0)