Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Create a zip archive via Google Cloud Build step to publish it as an artifact

I'm building a modern WP theme via GCB, and I need a final artifact, a ZIP package. Being new to the GCBб I didn't manage to solve it on my own, but it sounds so obvious

Anyway, here's my final build step

- name: 'gcr.io/cloud-builders/yarn'
  args: ['build:production']

I need to create a ZIP archive of the yarn output, recursively including all folder except node_modules, and publish the ZIP as an artifact (this part is clear, and I already got the storage bucket working).

Appreciate the help!

like image 985
Alex Balabanov Avatar asked May 02 '19 07:05

Alex Balabanov


1 Answers

So, hopefully, this answer will help someone. I created a custom build step, a very simple one:

Dockerfile

FROM ubuntu
RUN apt-get -q update && \
apt-get -qqy install zip bzip2 gzip

ENTRYPOINT ["zip"]

cloudbuild.yaml

steps:
- name: gcr.io/cloud-builders/docker
  args: ['build', '-t', 'gcr.io/$PROJECT_ID/zip', '.']

images: ['gcr.io/$PROJECT_ID/zip']

And used it this way

- name: gcr.io/$PROJECT_ID/zip
  args: ['-r9T', 'theme-$BUILD_ID.zip', '.', '-x *node_modules*']  
like image 178
Alex Balabanov Avatar answered Oct 27 '22 15:10

Alex Balabanov