[Automation] Update Toolchain #19
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 toolchain | |
on: | |
schedule: | |
- cron: "0 0 * * 0" | |
workflow_dispatch: | |
env: | |
BRANCH_NAME: chore/update-toolchain | |
jobs: | |
update-toolchain: | |
runs-on: ["ledgerhq-device-sdk"] | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: LedgerHQ/device-sdk-ts/.github/actions/setup-toolchain-composite@develop | |
- name: Setup git and branch | |
run: | | |
git config user.name 'github-actions[bot]' | |
git config user.email 'github-actions[bot]@users.noreply.github.com' | |
git checkout -b ${{ env.BRANCH_NAME }} | |
- name: Update toolchain | |
run: | | |
proto outdated --update | |
- name: Check for changes | |
id: changes | |
run: | | |
echo "status=$(git status --porcelain | wc -l)" >> $GITHUB_OUTPUT | |
- name: Set new versions | |
if: steps.changes.outputs.status > 0 | |
id: new-versions | |
run: | | |
proto use | |
pnpm i | |
echo "version=$(pnpm -v)" >> $GITHUB_OUTPUT | |
- name: Update package.json | |
if: steps.changes.outputs.status > 0 | |
run: | | |
jq '.packageManager = "pnpm@${{ steps.new-versions.outputs.version }}"' package.json > tmp.json && mv tmp.json package.json | |
- name: Health check | |
if: steps.changes.outputs.status > 0 | |
id: health-check | |
run: pnpm health-check | |
- name: Tests | |
id: unit-tests | |
if: steps.changes.outputs.status > 0 && success() | |
run: pnpm test:coverage -- --max-warnings=0 | |
- name: Create PR | |
if: steps.changes.outputs.status > 0 && success() | |
run: | | |
git add .prototools | |
git add package.json | |
git commit -m "🔧 (repo) [NO-ISSUE]: Update toolchain" | |
git push origin ${{ env.BRANCH_NAME }} | |
gh pr create \ | |
--title "🔧 (repo) [NO-ISSUE]: Update toolchain" \ | |
--body "This PR updates the toolchain (node, npm, pnpm) to the newest versions" \ | |
--base develop \ | |
--head ${{ env.BRANCH_NAME }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |