Following up on the previous post that explains how to setup the OCI Gradle Build Cache plugin on Travis-CI today I’d like to show how to do the same with GitHub Actions. The steps to follow are quite similar; if you do not already have an OCI account and/or a configured compartment then please follow steps 1, 2, and 3 as explained in this post, then proceed with the next steps
Step 4: Apply the plugin to your project
Paste the following into your
Notice that the location of the config file is local to the project. There’s an environment variable named COMPARTMENT_ID whose value will be set based on a secret stored in the repository’s settings. We’ll see how to manage that in just a second.
Step 5: Encrypt the configuration files
There are 2 files that need to be encrypted just like before: the OCI configuration file (
.oci/config) and the decryption key (
.oci/oci_api_key.pem). Just like Travis-CI, GitHub Actions allow a single file to be encrypted thus we must package all files in a single archive and encrypt; the documentation page is quite good
$ tar cvf .github-secrets.tar .oci/config .oci/oci_api_key.pem $ gpg --symmetric --cipher-algo AES256 .github-secrets.tar $ git add .github-secrets.tar.enc $ git commit -m 'use secret archive' $ git push
Next create a script for decrypting the secrets and commit it to the repository
$ mkdir .github/scripts $ vi .github/scripts/decrypt_secret.sh $ git add .github/scripts/decrypt_secret.sh $ git commit -m 'add decryption script' $ git push
Finally add 2 secret values to your project settings. One key should be COMPARTMENT_ID and the other DECRYPT_PASSPHRASE as shown here
Step 6: Create a workflow
You have a few choices to create a workflow. You can navigate to “Actions” tab found at your porject’s page and create a new workflow or you create a file locally and push it. I decided to store my workflow on a file named gradle.yml, stored on .github/workflows. The contents of this file look like this
Step 7: Run a build
All that’s left is for you to trigger a build. If everything is configured correctly you should see a banner like the following one on build’s output. This means the plugin is active.
After the build is done, navigate to your OCI console and find the “Object Storage” menu item, the
build-cache bucket should contain new elements based on data collected by the build.
And that’s all that there is to it folks. Once you have an OCI account, configuration file, and write access rights to a compartment as shown in steps 1, 2, and 3, the rest is pretty straight forward. Have a happy and speedy builds.
Keep on coding!