Skip to content

Commit

Permalink
test: return randomWord
Browse files Browse the repository at this point in the history
  • Loading branch information
777abhi committed May 31, 2023
1 parent 4af6d23 commit defc293
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
8 changes: 4 additions & 4 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,12 @@ jobs:
- name: Set up Node.js
uses: actions/setup-node@v2

- name: Run JavaScript File
- name: Run JavaScript File and Set Output Environment Variable
id: random_word
run: |
node random-word.js
env
randomWord=$(node random-word.js)
echo "RANDOM_WORD=${randomWord}" >> $GITHUB_ENV
- name: Display RANDOM_WORD
run: |
echo "RANDOM_WORD=${{ steps.random_word }}"
echo "RANDOM_WORD=${{ env.RANDOM_WORD }}"
5 changes: 4 additions & 1 deletion random-word.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ const words = ['apple', 'banana', 'orange', 'grape', 'melon', 'pear'];
const randomIndex = Math.floor(Math.random() * words.length);
const randomWord = words[randomIndex];

process.env.RANDOM_WORD = randomWord;


console.log('Random word:', randomWord);
console.log('Environment variable RANDOM_WORD:', process.env.RANDOM_WORD);


module.exports = randomWord;

0 comments on commit defc293

Please sign in to comment.