Publish wrapper workflow (nhn/tui.image-editor)
The Publish wrapper workflow from nhn/tui.image-editor, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Publish wrapper workflow from the nhn/tui.image-editor repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Publish wrapper
on: [workflow_dispatch]
env:
WORKING_DIRECTORY: ./apps/image-editor
REACT_WRAPPER_DIRECTORY: ./apps/react-image-editor
VUE_WRAPPER_DIRECTORY: ./apps/vue-image-editor
jobs:
publish-wrapper:
runs-on: ubuntu-latest
steps:
- name: Checkout branch
uses: actions/checkout@v2
- name: Install root dependencies
uses: ./.github/composite-actions/install-dependencies
- name: Use Node.js 15.x
uses: actions/setup-node@v1
with:
node-version: '15.x'
registry-url: https://registry.npmjs.org/
- name: Get package version
id: version
uses: PostHog/check-package-version@v2
with:
path: ${{ env.WORKING_DIRECTORY }}/
- name: Update version of wrappers in package.json
working-directory: ${{ env.WORKING_DIRECTORY }}
run: |
npm run update:wrapper
- name: Update lock file of react wrapper
working-directory: ${{ env.REACT_WRAPPER_DIRECTORY }}
run: |
npm install
- name: Build react wrapper
working-directory: ${{ env.REACT_WRAPPER_DIRECTORY }}
run: |
npm run build
- name: Update lock file of Vue wrapper
working-directory: ${{ env.VUE_WRAPPER_DIRECTORY }}
run: |
npm install
- name: Build vue wrapper
working-directory: ${{ env.VUE_WRAPPER_DIRECTORY }}
run: |
npm run build
- name: Commit files
run: |
rm -rf ./apps/react-image-editor/package-lock.json
rm -rf ./apps/vue-image-editor/package-lock.json
git config --local user.name "lja1018"
git config --local user.email "jaeeon.lim@nhn.com"
git add .
git commit -m "chore: update version of wrappers to v${{ steps.version.outputs.committed-version }}"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: master
- name: Publish react wrapper
working-directory: ${{ env.REACT_WRAPPER_DIRECTORY }}
run: |
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
- name: Publish vue wrapper
working-directory: ${{ env.VUE_WRAPPER_DIRECTORY }}
run: |
npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: Publish wrapper on: [workflow_dispatch] env: WORKING_DIRECTORY: ./apps/image-editor REACT_WRAPPER_DIRECTORY: ./apps/react-image-editor VUE_WRAPPER_DIRECTORY: ./apps/vue-image-editor jobs: publish-wrapper: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Checkout branch uses: actions/checkout@v2 - name: Install root dependencies uses: ./.github/composite-actions/install-dependencies - name: Use Node.js 15.x uses: actions/setup-node@v1 with: cache: 'npm' node-version: '15.x' registry-url: https://registry.npmjs.org/ - name: Get package version id: version uses: PostHog/check-package-version@v2 with: path: ${{ env.WORKING_DIRECTORY }}/ - name: Update version of wrappers in package.json working-directory: ${{ env.WORKING_DIRECTORY }} run: | npm run update:wrapper - name: Update lock file of react wrapper working-directory: ${{ env.REACT_WRAPPER_DIRECTORY }} run: | npm install - name: Build react wrapper working-directory: ${{ env.REACT_WRAPPER_DIRECTORY }} run: | npm run build - name: Update lock file of Vue wrapper working-directory: ${{ env.VUE_WRAPPER_DIRECTORY }} run: | npm install - name: Build vue wrapper working-directory: ${{ env.VUE_WRAPPER_DIRECTORY }} run: | npm run build - name: Commit files run: | rm -rf ./apps/react-image-editor/package-lock.json rm -rf ./apps/vue-image-editor/package-lock.json git config --local user.name "lja1018" git config --local user.email "jaeeon.lim@nhn.com" git add . git commit -m "chore: update version of wrappers to v${{ steps.version.outputs.committed-version }}" - name: Push changes uses: ad-m/github-push-action@master with: github_token: ${{ secrets.GITHUB_TOKEN }} branch: master - name: Publish react wrapper working-directory: ${{ env.REACT_WRAPPER_DIRECTORY }} run: | npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} - name: Publish vue wrapper working-directory: ${{ env.VUE_WRAPPER_DIRECTORY }} run: | npm publish env: NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.