Skip to content

workflow - access env var in nodejs #8

workflow - access env var in nodejs

workflow - access env var in nodejs #8

Workflow file for this run

name: Using Secrets
on:
push:
branches:
- using-secrets
env:
DB_NAME: ${{secrets.MY_SECRET}}
jobs:
test-env-vars:
environment: test
runs-on: ubuntu-latest
steps:
- name: test environment variables
run: |
echo "ENV var from yaml env conf - 1" - $DB_NAME
echo "ENV var from yaml env conf - 2" - ${{env.DB_NAME}}
echo "ENV var from github environment settings" - ${{vars.ENV_DB_NAME}}
test-env-secrets:
environment: test
runs-on: ubuntu-latest
steps:
- name: test environment secrets
run: |
echo "ENV secrets from github environment settings" - ${{secrets.MY_SECRET}}
echo "Above echo will not print the value, since secret is actually a secret and not exposed anywhere"
build:
runs-on: ubuntu-latest
steps:
- name: Get Code
uses: actions/checkout@v4
- name: Folder content
working-directory: ./nodejs-demo
run: ls
- name: Cache dependencies
uses: actions/cache@v4
with:
path: ~/.npm
key: deps-node-modules-${{ hashFiles('./nodejs-demo/package-lock.json') }}
- name: Install dependencies
working-directory: ./nodejs-demo
run: npm ci
- name: Build
working-directory: ./nodejs-demo
run: npm start