build: lock file maintenance #1043
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: on branch push | |
on: | |
pull_request: | |
push: | |
branches: | |
- '*' # matches every branch that doesn't contain a '/' | |
- '*/*' # matches every branch containing a single '/' | |
- '**' # matches every branch | |
# This allows a subsequently queued workflow run to interrupt previous runs | |
concurrency: | |
group: '${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}' | |
cancel-in-progress: true | |
jobs: | |
prettier: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: dafnik/setup-node-pnpm@v3 | |
with: | |
install-ignore-scripts: true | |
- name: Style check | |
run: pnpm format:check | |
eslint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: dafnik/setup-node-pnpm@v3 | |
with: | |
install-ignore-scripts: true | |
- name: Lint project | |
run: pnpm lint:check | |
commitlint: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- uses: dafnik/setup-node-pnpm@v3 | |
with: | |
install-ignore-scripts: true | |
- name: Validate current commit (last commit) with commitlint | |
if: github.event_name == 'push' | |
run: pnpm exec commitlint --from HEAD~1 --to HEAD --verbose | |
- name: Validate PR commits with commitlint | |
if: github.event_name == 'pull_request' | |
run: pnpm exec commitlint --from ${{ github.event.pull_request.head.sha }}~${{ github.event.pull_request.commits }} --to ${{ github.event.pull_request.head.sha }} --verbose | |
# JOB to run change detection | |
changes: | |
runs-on: ubuntu-latest | |
# Required permissions | |
permissions: | |
pull-requests: read | |
outputs: | |
# Expose matched filters as job 'packages' output variable | |
libs: ${{ steps.filter.outputs.changes }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dorny/paths-filter@v3 | |
id: filter | |
with: | |
filters: | | |
dfts-helper: | |
- 'libs/dfts-helper/**' | |
- '{package,nx,migrations,tsconfig.base}.json' | |
- 'pnpm-lock.yaml' | |
- '.github/**' | |
dfts-qrcode: | |
- 'libs/dfts-qrcode/**' | |
- '{package,nx,migrations,tsconfig.base}.json' | |
- 'pnpm-lock.yaml' | |
- '.github/**' | |
dfx-bootstrap-table: | |
- 'libs/dfx-bootstrap-table/**' | |
- '{package,nx,migrations,tsconfig.base}.json' | |
- 'pnpm-lock.yaml' | |
- '.github/**' | |
dfx-helper: | |
- 'libs/dfx-helper/**' | |
- '{package,nx,migrations,tsconfig.base}.json' | |
- 'pnpm-lock.yaml' | |
- '.github/**' | |
dfx-qrcode: | |
- 'libs/dfx-qrcode/**' | |
- '{package,nx,migrations,tsconfig.base}.json' | |
- 'pnpm-lock.yaml' | |
- '.github/**' | |
dfx-bootstrap-icons: | |
- 'libs/dfx-bootstrap-icons/**' | |
- '{package,nx,migrations,tsconfig.base}.json' | |
- 'pnpm-lock.yaml' | |
- '.github/**' | |
test: | |
name: Test ${{ matrix.lib }} | |
runs-on: ubuntu-latest | |
continue-on-error: true | |
needs: changes | |
if: ${{ needs.changes.outputs.libs != '[]' && needs.changes.outputs.libs != '' }} | |
strategy: | |
matrix: | |
lib: ${{ fromJSON(needs.changes.outputs.libs) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: setup node and pnpm | |
uses: dafnik/setup-node-pnpm@v3 | |
with: | |
install-ignore-scripts: true | |
- name: test ${{ matrix.lib }} | |
run: pnpm exec nx test ${{ matrix.lib }} --configuration=ci --coverageReporters=cobertura --coverageDirectory="coverage/libs/${{ matrix.lib }}" | |
- name: setup coverage report | |
uses: ./.github/actions/setup-coverage-report | |
with: | |
path: coverage/libs/${{ matrix.lib }}/cobertura-coverage.xml | |
build-lib: | |
name: Build ${{ matrix.lib }} | |
runs-on: ubuntu-latest | |
needs: changes | |
if: ${{ needs.changes.outputs.libs != '[]' && needs.changes.outputs.libs != '' }} | |
strategy: | |
matrix: | |
lib: ${{ fromJSON(needs.changes.outputs.libs) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: setup node and pnpm | |
uses: dafnik/setup-node-pnpm@v3 | |
with: | |
install-ignore-scripts: true | |
- name: build ${{ matrix.lib }} | |
run: pnpm exec nx build ${{ matrix.lib }} | |
- name: zip ${{ matrix.lib }} | |
run: | | |
cd ./dist/libs/ | |
zip -r "${{ matrix.lib }}.zip" ./${{ matrix.lib }} | |
cd - | |
- uses: actions/upload-artifact@v4 | |
name: create ${{ matrix.lib }} artifact | |
with: | |
name: ${{ matrix.lib }} | |
path: ./dist/libs/${{ matrix.lib }}.zip | |
retention-days: 1 | |
deploy-lib: | |
name: Deploy ${{ matrix.lib }} dev | |
needs: [build-lib, test, changes] | |
runs-on: ubuntu-latest | |
if: github.ref == 'refs/heads/main' | |
strategy: | |
matrix: | |
lib: ${{ fromJSON(needs.changes.outputs.libs) }} | |
steps: | |
- uses: actions/download-artifact@v4 | |
with: | |
name: ${{ matrix.lib }} | |
path: ./dist | |
- name: dist lookup | |
run: | | |
cd dist | |
mv ${{ matrix.lib }}.zip ./${{ matrix.lib }}-dev.zip | |
ls -la | |
cd - | |
- name: copy build to release server | |
uses: appleboy/scp-action@v0.1.7 | |
with: | |
host: ${{ secrets.RELEASES_SSH_HOST }} | |
username: ${{ secrets.RELEASES_SSH_USER }} | |
key: ${{ secrets.RELEASES_SSH_PRIVATE_KEY }} | |
port: ${{ secrets.RELEASES_SSH_PORT }} | |
source: dist/* | |
target: /var/www/share/releases/${{ matrix.lib }} | |
overwrite: true | |
build-apps: | |
name: Build ${{ matrix.app }} | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
app: ['dfx-bootstrap-table-demo', 'dfx-bootstrap-icons-demo', 'dfx-qrcode-demo', 'playground'] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: setup node and pnpm | |
uses: dafnik/setup-node-pnpm@v3 | |
with: | |
install-ignore-scripts: true | |
- name: build ${{ matrix.app }} | |
run: pnpm exec nx build ${{ matrix.app }} | |
- name: zip ${{ matrix.app }} | |
run: | | |
cd ./dist/apps/ | |
zip -r "${{ matrix.app }}.zip" ./${{ matrix.app }} | |
cd - | |
- uses: actions/upload-artifact@v4 | |
name: create ${{ matrix.app }} artifact | |
with: | |
name: ${{ matrix.app }} | |
path: ./dist/apps/${{ matrix.app }}.zip | |
retention-days: 1 | |
bundle-apps: | |
name: Bundle app artifacts into one | |
needs: [build-apps] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/download-artifact@v4 | |
name: Download table-demo | |
with: | |
name: dfx-bootstrap-table-demo | |
- uses: actions/download-artifact@v4 | |
name: Download icons-demo | |
with: | |
name: dfx-bootstrap-icons-demo | |
- uses: actions/download-artifact@v4 | |
name: Download qrcode-demo | |
with: | |
name: dfx-qrcode-demo | |
- uses: actions/download-artifact@v4 | |
name: Download playground | |
with: | |
name: playground | |
- name: unzip all | |
run: | | |
unzip dfx-bootstrap-table-demo.zip | |
unzip dfx-bootstrap-icons-demo.zip | |
unzip dfx-qrcode-demo.zip | |
unzip playground.zip | |
- name: move files in place | |
run: | | |
mkdir dist | |
mkdir dist/bootstrap-table | |
mkdir dist/bootstrap-icons | |
mkdir dist/qrcode | |
mkdir dist/base64-pdf-converter | |
mv playground/* dist/ | |
mv dfx-bootstrap-table-demo/* dist/bootstrap-table/ | |
mv dfx-bootstrap-icons-demo/* dist/bootstrap-icons/ | |
mv dfx-qrcode-demo/* dist/qrcode/ | |
- name: dist lookup | |
run: | | |
cd dist | |
ls -la | |
du -hs | |
cd - | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: ./dist/ | |
retention-days: 1 | |
deploy-apps: | |
if: github.ref == 'refs/heads/main' | |
name: Deploy apps | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: bundle-apps | |
permissions: | |
actions: read | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |