Skip to content

Commit

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

Upload image to gcloud
  • Loading branch information
blackpiglet authored Nov 25, 2022
2 parents 4874205 + ffe12ac commit 88307ef
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 3 deletions.
29 changes: 27 additions & 2 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,20 @@ 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 +66,17 @@ jobs:
if: github.repository == 'vmware-tanzu/velero-plugin-for-gcp'
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-gcp image package to GCS
source hack/ci/build_util.sh
BIN=velero-plugin-for-gcp
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}
7 changes: 6 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +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 88307ef

Please sign in to comment.