Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Github Action step to extract .zip file?

Is there a way to extract the contents of a .zip file as part of a Github Action with a Windows runner?

I can't seem to find a reference for things like renaming files, unzipping/zipping, etc.

like image 748
SeaDude Avatar asked Dec 17 '22 11:12

SeaDude


2 Answers

GitHub Actions just provides you with an operating system (Windows in your case), so the question is in fact, how would you do it in Windows command line. Once you know how to do this, you can do it on GitHub Actions.

GitHub Actions documentation provides a list of pre-installed software on the runners, and more particularly, the Tools section on the Windows Server 2019 runner - specifies that 7zip is installed.

So, it should be a matter of just running 7z x archive.zip in your step, or whatever the command you need.

steps:
- name: Checkout code
  uses: actions/checkout@v2

- name: Extract some files
  run: 7z x archive.zip

# ...

If I were you, I would install 7zip locally, in order to figure out exactly how its CLI works, so you can just paste it later in a GitHub Action configuration file.

like image 124
DannyB Avatar answered Dec 31 '22 14:12

DannyB


I can't seem to find a reference for things like renaming files, unzipping/zipping, etc.

Since you're using Windows, you can do everything you asked for using the built-in PowerShell. For working with .zip files, you would use Expand-Archive to open zip files and Compress-Archive to create zip files. Rename-Item is used to rename files and folders.

like image 37
abhi Avatar answered Dec 31 '22 16:12

abhi