Skip to content

Codeforafrica Stories #541

Codeforafrica Stories

Codeforafrica Stories #541

# When dependabot bumps dependencies versions, a new pnpm-lock.yml file
# is generated. This file needs to be formatted
# https://docs.github.com/en/code-security/dependabot/working-with-dependabot/automating-dependabot-with-github-actions
name: Dependabot lint-format
on: pull_request
permissions:
contents: write
jobs:
dependabot:
runs-on: ${{ matrix.os }}
strategy:
matrix:
node-version: [18]
os: [ubuntu-latest]
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
# https://github.com/pnpm/action-setup#use-cache-to-reduce-installation-time
- name: Install pnpm
uses: pnpm/action-setup@v2
id: pnpm-install
with:
version: 8
run_install: false
- name: Get pnpm store directory
id: pnpm-cache
shell: bash
run: |
echo "STORE_PATH=$(pnpm store path)" >> $GITHUB_OUTPUT
- name: Setup pnpm cache
uses: actions/cache@v3
with:
path: ${{ steps.pnpm-cache.outputs.STORE_PATH }}
key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-store-
# Looks like to use pnpm cache, setup-node must run after pnpm/action-setup
# https://github.com/actions/setup-node/blob/main/docs/advanced-usage.md#caching-packages-data
- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: "pnpm"
- name: Confirm pnpm version
run: pnpm --version
- name: Install dependencies
run: pnpm install
- name: Format pnpm-lock.yaml
run: pnpm prettier --write './pnpm-lock.yaml'
- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Format & lint pnpm-lock.yaml
file_pattern: "./pnpm-lock.yaml"
- name: "Run lint (If there are changes)"
if: steps.auto-commit-action.outputs.changes_detected == 'true'
run: pnpm lint-check
- name: "Run test (If there are changes)"
if: steps.auto-commit-action.outputs.changes_detected == 'true'
run: pnpm test
- name: "Run build (If there are changes)"
if: steps.auto-commit-action.outputs.changes_detected == 'true'
run: pnpm build --filter=promisetracker^...