# .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: # Reusing other Workflows does not work on Gitea yet (17.07.2023) So GitHub only for now. #- name: Use Other (reuse.yml) Workflow # uses: ./.gitea/workflows/reuse.yml # with: # person: ChatGPT - name: Error on purpose id: failingstep continue-on-error: true run: exit 1 #- name: Continue with this step anyway # if: ${{ failure() && steps.failingstep.conclusion == 'failure' }} # run: echo "Still running... ${{toJSON(steps)}}" - name: Checkout Code uses: actions/checkout@v3 - name: Install NodeJS uses: actions/setup-node@v3 with: node-version: '18' - uses: KEINOS/gh-action-hash-for-cache@v2.0.0-alpha id: get-cache-hash with: path: | 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-${{ steps.get-cache-hash.outputs.hash }} - 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: Checkout Code uses: actions/checkout@v3 - uses: KEINOS/gh-action-hash-for-cache@v2.0.0-alpha id: get-cache-hash with: path: | 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-${{ steps.get-cache-hash.outputs.hash }} - 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! #Notify-Commiter-Error: # needs: Deploy # runs-on: ubuntu-latest # if: ${{ failure() }} # steps: # - name: Blame commiter # run: echo "OMG YOU BROKE THE BUILD!!! FIX IT"