Skip to content

Commit

Permalink
test: pass var generated by node script
Browse files Browse the repository at this point in the history
  • Loading branch information
777abhi committed May 31, 2023
1 parent 1750b52 commit 931c49f
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
18 changes: 17 additions & 1 deletion .github/workflows/master.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,20 @@ jobs:
runs-on: ubuntu-latest
needs: job1
steps:
- run: echo ${{ needs.job1.outputs.firstword }} ${{ needs.job1.outputs.secondword }}
- run: echo ${{ needs.job1.outputs.firstword }} ${{ needs.job1.outputs.secondword }}
job3:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Set up Node.js
uses: actions/setup-node@v2

- name: Run JavaScript File
id: random_word
run: node random-word.js

- name: Display Random Word
run: |
echo "The random word is ${{ steps.random_word.outputs.RANDOM_WORD }}"
7 changes: 7 additions & 0 deletions random-word.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
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);

0 comments on commit 931c49f

Please sign in to comment.