I have a Ruby gem which I've been building with Travis but I want to make the transition to GitHub actions. I took the example Ruby gem action and expanded upon it somewhat, but I feel it could be further improved. The file as it stands now:
As you can see I have three jobs:
What I would like to improve:
Solved! Solved! Go to Solution.
preserve the project directory and the next step would continue from that point.
No caching available yet...
EDIT: Posted too fast... next step or next job?
Everything is in place until job finishes, so everything* you do in one step is visible in another.
If it's about next job, currently only way to pass files from job to job is to upload files in one job and download in another (for example using actions/upload-artifact + actions/download-artifact).
*Current directory changes on each step; if you `cd my_dir` in one step, next one will push you back where you started.
- Is it possible to somehow separate the publish job so that it doesn't even start on branches that are different from master?
You have a small mistake there;
if: github.ref == 'master'
if: github.ref == 'refs/heads/master'
If you want to skip whole job, move that check under `job.<id>`
publish: runs-on: ubuntu-latest if: github.ref == 'refs/heads/master'
Thank you for the hints. I moved the if statement and indeed it's skipping that job altogether.
As for artifact uploading and downloading: I printed out where it is installing the gems and it said: /opt/hostedtoolcache/Ruby/2.6.3/x64/lib/ruby/gems/2.6.0/gems - so I thought I'll upload that directory as an artifact and download it in the next job. The problem is that that directory is huge, because as its name says it's basically a systemwide cache. And since the upload was progressing really slowly I canceled it, but I'm not sure it would have worked anyway because AFAIK bundle install does some linking too.
The good news is that as stated here they're currently working on caching, so I won't try reinvent the wheel, I'll just wait patiently.