3 min read

Unlocking the Power of GitHub Actions Secrets

Explore the potential of GitHub Actions Secrets and unleash their power for secure and efficient automation in your workflows
Unlocking the Power of GitHub Actions Secrets
Photo by Sai De Silva / Unsplash


GitHub Actions is an automation tool that helps developers build, test, and deploy code directly from your GitHub repository. 

One of the key features contributing to the security and efficiency of workflows is the use of secrets. 

In this article, we'll explore what secrets are, why they are crucial, where to configure them on GitHub and provide a practical example showcasing the use of secrets in a workflow.

What are GitHub Actions Secrets?

GitHub Actions secrets are encrypted environment variables that store sensitive information such as API keys, access tokens, connection strings, and other credentials. 

Once stored and configured, these secrets can accessed in your GitHub Actions workflows without exposing them in the workflow files or logs.

Why Do We Need Secrets?

Securing sensitive information is paramount in software development and deployment. By using GitHub Actions secrets, you can:

  • Protect Sensitive Data - secures critical information, such as API keys or credentials.
  • Enhance Workflow Security - prevent exposing sensitive data in plain text within your workflow files.
  • Facilitate Collaboration - enable collaboration on projects without compromising security.

Where to Configure GitHub Actions Secrets?

Configuring GitHub Actions secrets is a straightforward process. Follow these steps:

  1. Go to your GitHub repository.
  2. Click on the "Settings" tab.
  3. Find and click " Secrets " In the left sidebar."
  4. Click "New repository secret" to create a new secret.
  5. Please enter a name for your secret and its corresponding value.
GitHub Action Secrets
GitHub Action Secrets

Example: Accessing Azure Storage Container Name with GitHub Actions Secrets

In this scenario, we want to display the name of an Azure Storage Container by passing the connection strings and a query.

Configure Secrets:

AZURE_STORAGE_CONNECTION_STRINGS: the value will be coming from the Azure portal.

We can get the value of connection strings from the Azure portal's "Access keys" section under a specific storage account.

Create a Workflow File:

name: Access Azure Storage Container Name

      - main

    name: Display Container Name
    runs-on: ubuntu-latest
      - name: Step one checkout
        uses: actions/checkout@v2
      - name: Azure CLI Action
        uses: Azure/cli@v1.0.8
          azcliversion: 2.30.0 
          inlineScript: |
            az storage container list --connection-string "${{ secrets.AZURE_STORAGE_CONNECTION_STRINGS }}" --query "[].name"

Run the Workflow:

GitHub Actions Workflow

It will be automatically triggered after you commit and make your changes.

GitHub Actions will securely provide the secrets to the workflow, enabling the secure retrieval of Azure Storage container names. But

Once you have followed these steps, you can seamlessly integrate GitHub Actions secrets into your workflows.

See the actions below.



In this article, we delved into the essential role of GitHub Actions secrets in enhancing the security and efficiency of your workflows. 

GitHub Actions secrets and encrypted environment variables are secure means to store and use sensitive information, ranging from API keys to access tokens.

 By utilizing these secrets while maintaining collaborative development practices, developers can fortify their workflows against potential security. 

I hope you have enjoyed this article. Till next time, happy programming and happy cloud computing!

Please don't forget to subscribe, bookmark, like, and comment. Cheers! and Thank you!