Skip to content

add output

add output #59

Workflow file for this run

name: Test Project
on:
pull_request:
types:
- opened
workflow_dispatch:
push:
branches:
- main
jobs:
test:
runs-on: ubuntu-latest
outputs:
script-file: ${{steps.publish.outputs.file-name}}
services:
mongodb:
image: mongo
env:
MONGO_INITDB_ROOT_USERNAME: root
MONGO_INITDB_ROOT_PASSWORD: example
steps:
- name: Get code
uses: actions/checkout@v4
- name: Install nodejs
uses: actions/setup-node@v4
with:
node-version: 18
- name: load & cahce dependencies
uses: ./.github/actions/cache-deps
id: caching
with:
caching: 'false'
- name: ouput information
run: |
echo "caching name ${{steps.caching.outputs.used-cache}}"
- name: Run tests
continue-on-error: true
id: run-tests
run: npm run test
- name: upload test report
uses: actions/upload-artifact@v3
with:
name: test-report
path: test.json
- name: build website
run: npm run build
- name: publish output
id: publish
# run: find dist/assets/*.js -type f -execdir echo 'file-name={}' >> $GITHUB_OUTPUT ';'
run: find dist/assets/*.js -type f -execdir echo '::set-output name=file-name::{}' ';'
- name: Upload artifacts
uses: actions/upload-artifact@v3
with:
name: dist-files
path: |
dist
package.json
deploy:
env:
DATABASE_NAME: test
DATABASE_PAWSSORD: ${{ secrets.DATABASE_PAWSSORD }}
needs: test
runs-on: ubuntu-latest
container:
image: node:16
steps:
- name: Get code
uses: actions/checkout@v4
- name: Install nodejs
uses: actions/setup-node@v4
with:
node-version: 18
- name: cache dependencies
uses: actions/cache@v3
with:
path: ~/.npm
key: deps-node-modules-${{ hashFiles('**/package-lock.json') }}
- name: down load artifacts
uses: actions/download-artifact@v3
with:
name: dist-files
- name: Install dependencies
run: npm ci
- name: output contents
run: ls dist/
- name: echo env
run: |
echo "DATABASE_NAME: $DATABASE_NAME"
echo "DATABASE_PAWSSORD: $DATABASE_PAWSSORD"
- name: get output
run: echo "${{ needs.test.outputs.script-file }}"
- name: Deploy
run: echo "deploying"
reusing:
needs: test
uses: ./.github/workflows/reusable.yml
with:
artifact-name: dist-files
print-result:
needs: reusing
runs-on: ubuntu-latest
steps:
- name: print result
run: echo "${{needs.reusing.outputs.result}}"
javascript:
runs-on: ubuntu-latest
steps:
- name: Get code
uses: actions/checkout@v4
- name: Run java script action
id: javascript
uses: ./.github/actions/deploy-s3-javascript
env:
AWS_ACCESS_KEY: ${{ secrets.AWS_ACCESS_KEY}}
AWS_SECURITY_KEY: ${{secrets.AWS_SECURITY_KEY}}
with:
bucket-name: tf-gavin-test-ghr
bucket-region: ap-northeast-1
dist-folder: test
- name: output website url
run: |
echo '${{steps.javascript.outputs.website-url}}'