Files
actions-playground/.gitea/workflows/build.yml
T
tom.coursow bc6b102b0e
Build Workflow / Build (push) Failing after 12s
Build Workflow / Deploy (push) Has been skipped
Update .gitea/workflows/build.yml
2023-07-15 02:06:23 +02:00

101 lines
3.3 KiB
YAML

# .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: Error on purpose
id: failingstep
run: exit 1
- name: Continue with this step anyway
if: ${{ 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: actions/setup-go@v3
with:
go-version: '1.20'
- 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-${{ 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=<JS-FILENAME>' 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: actions/setup-go@v3
with:
go-version: '1.20'
- 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-${{ 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!