Skip to content

Standardise GitHub Actions workflows #93

Standardise GitHub Actions workflows

Standardise GitHub Actions workflows #93

Workflow file for this run

name: Main
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: main-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
env:
# Among other things, opts out of Turborepo telemetry. See https://consoledonottrack.com/.
DO_NOT_TRACK: '1'
NODE_VERSION: 24
SOLANA_VERSION: 2.1.9
jobs:
lint:
name: Check styling
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Set up pnpm
uses: pnpm/action-setup@v6
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Compile JS and types
run: pnpm build
- name: Check linting
run: pnpm lint
tests:
name: Test
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install Solana ${{ env.SOLANA_VERSION }}
uses: solana-program/actions/install-solana@v1
with:
version: ${{ env.SOLANA_VERSION }}
- name: Set up pnpm
uses: pnpm/action-setup@v6
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Build and run tests
run: pnpm build && pnpm test
- name: Ensure working directory is clean
run: |
git status
test -z "$(git status --porcelain)"
release:
name: Release
runs-on: ubuntu-latest
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
needs: [lint, tests]
permissions:
contents: write
pull-requests: write
outputs:
published: ${{ steps.changesets.outputs.published }}
steps:
- name: Create GitHub App token
id: app-token
uses: actions/create-github-app-token@v3
with:
client-id: ${{ secrets.RELEASE_APP_CLIENT_ID }}
private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@v7
with:
token: ${{ steps.app-token.outputs.token }}
- name: Set up pnpm
uses: pnpm/action-setup@v6
- name: Set up Node.js
uses: actions/setup-node@v7
with:
node-version: ${{ env.NODE_VERSION }}
cache: pnpm
registry-url: 'https://registry.npmjs.org'
- name: Install dependencies
run: pnpm install --frozen-lockfile
- name: Create Release Pull Request or Publish
id: changesets
uses: changesets/action@v2.1.1
with:
github-token: ${{ steps.app-token.outputs.token }}
commit-message: 'Publish package'
pr-title: 'Publish package'
publish-script: pnpm publish-package
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
dependabot:
name: Dependabot
runs-on: ubuntu-latest
if: github.event_name == 'pull_request' && github.event.pull_request.user.login == 'dependabot[bot]' && github.repository == 'codama-idl/renderers-js-umi'
needs: [lint, tests]
permissions:
contents: write
pull-requests: write
steps:
- name: Fetch Dependabot metadata
id: metadata
uses: dependabot/fetch-metadata@v3
- name: Auto-approve the PR
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr review --approve "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Enable auto-merge
if: steps.metadata.outputs.update-type == 'version-update:semver-patch' || steps.metadata.outputs.update-type == 'version-update:semver-minor'
run: gh pr merge --auto --squash "$PR_URL"
env:
PR_URL: ${{ github.event.pull_request.html_url }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}