# .gitea/workflows/build.yaml name: Build Workflow on: workflow_dispatch: push: branches: - main paths-ignore: - '.gitea/workflows/*' jobs: Build: runs-on: ubuntu-latest outputs: # js-file: name of the output (choosen here) # steps-js-filename -> The ID of the step which will produce a output (see Publish JS Filename Step) # script-file -> The key name which contains the output (saved by the step - see Publish JS Filename Step) js-file: ${{ steps.publish-js-filename.outputs.script-file }} steps: - name: Checkout Code uses: actions/checkout@v3 - name: Install NodeJS uses: actions/setup-node@v3 with: node-version: '18' - uses: actions/go-hashfiles@v0.0.1 id: get-cache-hash with: patterns: |- **/package-lock.json - name: Show key future key value run: echo "deps-node-modules-${{ steps.get-cache-hash.outputs.hash }}" - name: Setup Chache uses: https://github.com/actions/cache@v3 with: path: ~/.npm key: deps-node-modules-${{ hashFiles('**/package-lock.json') }} - name: Install Dependencies run: npm ci - name: Run Tests run: npm test - name: Build run: npm run build - name: Publish JS Filename id: publish-js-filename # Finds the desired Javascript file and prints a string 'script-file=' which then gets saved in the $GITHUB_OUTPUT file run: find dist/assets/*.js -type f -execdir echo 'script-file={}' >> $GITHUB_OUTPUT ';' - name: Package Artifacts uses: https://github.com/thedoctor0/zip-release@0.7.1 with: type: 'tar' path: dist filename: 'dist.tar.gz' - name: Upload Artifacts uses: actions/upload-artifact@v3 with: name: dist.tar.gz path: dist.tar.gz Deploy: runs-on: ubuntu-latest needs: Build steps: - name: Setup Chache uses: actions/cache@v3 with: path: ~/.npm key: deps-node-modules-${{ hashFiles('**/package-lock.json') }} - name: Access Artifacts uses: https://github.com/actions/download-artifact@v3 with: name: dist.tar.gz - name: Output JS Filename from Build Job # needs can access all previous jobs an their outputs if the current job is in their 'needs' chain # js-file -> The output key defined in the Build job outputs area run: echo "${{ needs.build.outputs.js-file }}" - name: Deploy run: | echo Deploying... ls echo DONE!