Update formiojs Libs #37
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: Update formiojs Libs | |
on: | |
# schedule: | |
# * is a special character in YAMLso you have to quote this string | |
# - cron: '0 1 * * *' | |
workflow_dispatch: | |
inputs: | |
description: | |
description: 'Manual run of update Libs' | |
jobs: | |
updateLibs: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 0 | |
ref: "main" | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- if: ${{ steps.cache-npm.outputs.cache-hit != 'true' }} | |
name: List the state of node modules | |
continue-on-error: true | |
run: npm list | |
# run script in prem, extract to lib, update versions.txt on each file | |
- name: list folder | |
run: | | |
pwd | |
ls -ltr | |
- name: Use Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
cache: 'npm' | |
always-auth: 'true' | |
cache-dependency-path: ./.github/workspace/formiojs/package-lock.json | |
registry-url: 'https://nexus.tools.services.qld.gov.au/nexus/repository/npm_all/' | |
- name: List versions | |
working-directory: ./.github/workspace/formiojs | |
run: | # List versions | |
npm view formiojs versions | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NEXUSREADONLY2NPMTOKEN }} | |
- name: What changed | |
working-directory: ./.github/workspace/formiojs | |
run: | | |
export outdated=`npm outdated` | |
echo $outdated | |
outdated="${outdated//'%'/'%25'}" | |
outdated="${outdated//$'\n'/'%0A'}" | |
outdated="${outdated//$'\r'/'%0D'}" | |
echo 'OUTDATED_LIST=$outdated' >> $GITHUB_OUTPUT | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NEXUSREADONLY2NPMTOKEN }} | |
id: what-changed-data | |
- name: Update package.json | |
working-directory: ./.github/workspace/formiojs | |
run: | # Update package.json | |
npm update `npm outdated | awk '{print $1}' | tr '\n' ' ' ` | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NEXUSREADONLY2NPMTOKEN }} | |
- name: Install latest | |
working-directory: ./.github/workspace/formiojs | |
run: | # Install packages https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#use-private-packages | |
npm install --no-audit --ignore-scripts | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NEXUSREADONLY2NPMTOKEN }} | |
# `npm rebuild` will run all those post-install scripts for us. | |
- name: rebuild and prepare | |
run: npm rebuild && npm run prepare --if-present | |
- name: copy to dist | |
working-directory: ./.github/workspace/formiojs | |
run: | # Copy libraries | |
npm run copy-all | |
# todo work out how to extract 'outdated' to be commit message | |
- name: Create Pull Request | |
uses: peter-evans/create-pull-request@v4 | |
with: | |
commit-message: "update form.io js libraries ${{ steps.what-changed-ata.outputs.OUTDATED_LIST }}" | |
title: "update form.io formiojs libraries" | |
body: "update form.io js formiojs libraries ${{ steps.what-changed-ata.outputs.OUTDATED_LIST }}" | |
branch: update-formio-formiojs-libraries | |
base: main |