Skip to content

Commit

Permalink
Merge pull request #159 from danfengliu/cherry-pick-1.6-upload-image-…
Browse files Browse the repository at this point in the history
…to-gcloud

Cherry-pick: 1.6 Upload image build by Make CI to gcloud
  • Loading branch information
Lyndon-Li authored Nov 25, 2022
2 parents 9400aab + a33b836 commit 2046326
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 2 deletions.
28 changes: 26 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,19 @@ jobs:
id: go

- name: Check out code into the Go module directory
uses: actions/checkout@v2
uses: actions/checkout@v3

# Fix issue of setup-gcloud
- run: |
sudo apt-get install python2.7
export CLOUDSDK_PYTHON="/usr/bin/python2"
- uses: google-github-actions/setup-gcloud@v0
with:
version: '285.0.0'
service_account_key: ${{ secrets.GCS_SA_KEY }}
export_default_credentials: true
- run: gcloud info
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
Expand Down Expand Up @@ -54,4 +65,17 @@ jobs:
if: github.repository == 'vmware-tanzu/velero-plugin-for-microsoft-azure'
run: |
docker login -u ${{ secrets.DOCKER_USER }} -p ${{ secrets.DOCKER_PASSWORD }}
./hack/docker-push.sh
VERSION=$(./hack/docker-push.sh | grep 'VERSION:' | awk -F: '{print $2}' | xargs)
# Upload velero-plugin-for-microsoft-azure image package to GCS
source hack/ci/build_util.sh
BIN=velero-plugin-for-microsoft-azure
GCS_BUCKET=velero-builds
VELERO_PLUGIN_IMAGE=${BIN}-${VERSION}
VELERO_PLUGIN_IMAGE_FILE=${VELERO_PLUGIN_IMAGE}.tar.gz
VELERO_PLUGIN_IMAGE_BACKUP_FILE=${VELERO_PLUGIN_IMAGE}-'build.'${GITHUB_RUN_NUMBER}.tar.gz
cp ${VELERO_PLUGIN_IMAGE_FILE} ${VELERO_PLUGIN_IMAGE_BACKUP_FILE}
uploader ${VELERO_PLUGIN_IMAGE_FILE} ${GCS_BUCKET}
uploader ${VELERO_PLUGIN_IMAGE_BACKUP_FILE} ${GCS_BUCKET}
6 changes: 6 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,12 @@ endif
--build-arg=REGISTRY=$(REGISTRY) \
-f $(VELERO_DOCKERFILE) .
@echo "container: $(IMAGE):$(VERSION)"
ifeq ($(BUILDX_OUTPUT_TYPE)_$(REGISTRY), registry_velero)
docker pull $(IMAGE):$(VERSION)
rm -f $(BIN)-$(VERSION).tar
docker save $(IMAGE):$(VERSION) -o $(BIN)-$(VERSION).tar
gzip -f $(BIN)-$(VERSION).tar
endif

build-dirs:
@mkdir -p _output/bin/$(GOOS)/$(GOARCH)
Expand Down
9 changes: 9 additions & 0 deletions hack/ci/build_util.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/bash
set -x

set -e

function uploader {
gsutil cp $1 gs://$2/$1
gsutil -D setacl public-read gs://$2/$1 &> /dev/null
}

0 comments on commit 2046326

Please sign in to comment.