Blog
Engineering
2
minutes

GitHub Variables and Nx Reusable Workflows

At Qovery, we build our frontend using Nx and rely on the official nrwl/ci GitHub Actions. Our frontend requires third-party tokens during compile time, but we would like to avoid hardcoding them or using the .env file to define our tokens. The latter exposes our source code directly on GitHub, and even though it's not sensitive data, we don't want it to be easily scraped. As probably many others, we've faced issues when we dug into environment variables using this reusable workflow: https://github.com/nrwl/ci?tab=readme-ov-file#limited-secrets-support https://github.com/nrwl/ci/issues/92 https://github.com/nrwl/ci/issues/44 So, I wanted to share the lessons I learned from this experience.
Camille Tjhoa
Senior Software Engineer
Summary
Twitter icon
linkedin icon

First and foremost, we need to better understand GitHub Actions and its capabilities.

GitHub Secrets vs Variables

Github differentiates secrets from variables.

The main differences that are going to be important here for our use case are:

  • Secrets are for sensitive data and cannot be shared with reusable workflows
  • Variables are non-sensitive data and are shared to reusable workflows through the keyword vars

As mentioned earlier, our data consists of frontend third-party tokens that are not sensitive because they can be found in our public JS source code. Additionally, nx-cloud-main and nx-cloud-agents are reusable workflows.

Therefore, our solution should revolve around Variables.

Note that you can create repository variables in GitHub like this.

Secrets and Variables screen from GitHub

Nrwl/ci reusable workflow configuration

Although GitHub Variables may appear perfect in our case, the reusable workflows from nrwl/ci do not directly utilize the vars keyword internally. Therefore, variables are not used by those workflows as they are.

Upon closer examination of the workflow configuration, we find a parameter called "environment-variables". Unfortunately, this parameter requires environment variables in dotenv format:

NX_MY_TOKEN=1234
NX_MY_OTHER_TOKEN=4567

whereas our vars are an object

{
NX_MY_TOKEN: 1234
NX_MY_OTHER_TOKEN: 4567
}

GitHub script to the rescue

To achieve the desired format, we require some intermediate scripting. Luckily, the actions/github-script is the ideal tool for this task. It enables us to convert GitHub variables into the expected Nx format.

  env-vars:
runs-on: ubuntu-latest
outputs:
variables: ${{ steps.var.outputs.variables }}
steps:
- name: Setting global variables
uses: actions/github-script@v7
id: var
with:
script: |
const varsFromJSON = ${{ toJSON(vars) }}
const variables = []
for (const v in varsFromJSON) {
variables.push(v + '=' + varsFromJSON[v])
}
core.setOutput('variables', variables.join('\\n'))
nx-main:
needs: [env-vars]
name: Nx Cloud - Main Job
uses: nrwl/ci/.github/workflows/[email protected]
with:
environment-variables: |
${{ needs.env-vars.outputs.variables }}
# ...

agents:
needs: [env-vars]
name: Nx Cloud - Agents
uses: nrwl/ci/.github/workflows/[email protected]
with:
number-of-agents: 3
environment-variables: |
${{ needs.env-vars.outputs.variables }}

Conclusion

We have learned more about the capabilities of GitHub Actions and are taking our CI to the next level!

We can leverage our environment variables without exposing them directly by using a bit of scripting and the options provided by Nx workflows.

And the best part is we can achieve this without hardcoding them or using a .env file.

Share on :
Twitter icon
linkedin icon
Tired of fighting your Kubernetes platform?
Qovery provides a unified Kubernetes control plane for cluster provisioning, security, and deployments - giving you an enterprise-grade platform without the DIY overhead.
See it in action

Suggested articles

Kubernetes
6
 minutes
When Kubernetes Becomes the Bottleneck, and How to Fix It

Struggling with Kubernetes configuration sprawl and long deployment queues? Discover how to identify technical vs. workflow bottlenecks and why shifting to a self-service Kubernetes management platform like Qovery is the key to scaling your engineering velocity.

Mélanie Dallé
Senior Marketing Manager
DevOps
Kubernetes
Platform Engineering
6
 minutes
10 Red Hat OpenShift alternatives to reduce licensing costs

Is OpenShift too expensive? Compare the top 10 alternatives for 2026. Discover how to transition to Rancher, standard EKS, or modern K8s management platforms.

Morgan Perry
Co-founder
DevOps
6
 minutes
The enterprise guide to DevOps automation: scaling kubernetes and delivery pipelines

Scale your enterprise DevOps automation without configuration sprawl. Learn how a Kubernetes management platform like Qovery enables secure, self-service infrastructure.

Mélanie Dallé
Senior Marketing Manager
Product
Infrastructure Management
5
 minutes
Migrating from NGINX Ingress to Envoy Gateway (Gateway API): behind the scenes

Following the end of maintenance of the Ingress NGINX project, we have been working behind the scenes to migrate our customers’ clusters from Kubernetes Ingress + NGINX Ingress Controller to Gateway API + Envoy Gateway.

Benjamin Chastanier
Software Engineer
DevOps
Kubernetes
 minutes
How to reduce AI infrastructure costs with Kubernetes GPU partitioning

Stop wasting expensive AI compute. Learn how to reduce infrastructure costs using Kubernetes GPU partitioning (NVIDIA MIG) and automated scheduling.

Mélanie Dallé
Senior Marketing Manager
Kubernetes
DevOps
6
 minutes
Top Nutanix Alternatives for Kubernetes Management

Looking for alternatives to Nutanix Kubernetes Platform (NKP)? Compare the top 10 solutions. Review pros and cons to find tools that offer greater flexibility and lower costs.

Mélanie Dallé
Senior Marketing Manager
Kubernetes
DevOps
6
 minutes
Top Mirantis Alternatives That Developers Actually Love

Explore the top 10 alternatives to Mirantis. Compare pros and cons of modern Kubernetes platforms like Qovery, Rancher, and OpenShift to find your best fit.

Mélanie Dallé
Senior Marketing Manager
Kubernetes
DevOps
6
 minutes
Top 10 enterprise Kubernetes cluster management tools in 2026

Compare the best enterprise Kubernetes management tools for 2026. From Qovery and OpenShift to Rafay and Mirantis, discover which platform best suits your multi-cluster strategy.

Mélanie Dallé
Senior Marketing Manager

It’s time to change
the way you manage K8s

Turn Kubernetes into your strategic advantage with Qovery, automating the heavy lifting while you stay in control.