111k views
4 votes
How to access environment variables in GitHub actions?

User Cstoltze
by
7.9k points

1 Answer

3 votes

Final answer:

To access environment variables in GitHub actions, use the ${{ secrets.VARIABLE_NAME }} syntax.

Step-by-step explanation:

To access environment variables in GitHub actions, you can use the ${{ secrets.VARIABLE_NAME }} syntax. These variables can be defined in the 'Secrets' tab of your repository settings. Here's an example:

name: My Workflow

on: [push]

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Print Secret
run: |
echo ${{ secrets.MY_SECRET}}

User ManojP
by
7.7k points