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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With