feat: add workflow dispatch for cd runs #5
This file contains hidden or 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: CI | ||
| on: | ||
| pull_request: | ||
| branches: [master] | ||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: ./.github/actions/lint | ||
| test: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: ./.github/actions/test | ||
| sync-version: | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: write | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| with: | ||
| fetch-depth: 0 | ||
| - name: Sync package.json version | ||
| id: version-sync | ||
| run: | | ||
| ELM_VERSION=$(jq -r '.version' elm.json) | ||
| PKG_VERSION=$(jq -r '.version' package.json) | ||
| if [ "$ELM_VERSION" != "$PKG_VERSION" ]; then | ||
| pnpm version "$ELM_VERSION" --no-git-tag-version | ||
| echo "synced=true" >> $GITHUB_OUTPUT | ||
| else | ||
| echo "synced=false" >> $GITHUB_OUTPUT | ||
| fi | ||
| shell: bash | ||
| - name: Commit version sync | ||
| if: steps.version-sync.outputs.synced == 'true' | ||
| uses: stefanzweifel/git-auto-commit-action@v7 | ||
| with: | ||
| commit_message: chore: sync package.json version with elm.json | ||
| file_pattern: package.json pnpm-lock.yaml | ||
| branch: ${{ github.head_ref }} | ||
| check-publishable: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - uses: actions/checkout@v6 | ||
| - uses: pnpm/action-setup@v5 | ||
| - uses: actions/setup-node@v6 | ||
| with: | ||
| node-version: lts/* | ||
| cache: pnpm | ||
| - run: pnpm install | ||
| shell: bash | ||
| - name: Check if publishable | ||
| id: publish | ||
| uses: ./.github/actions/publish | ||
| with: | ||
| dry-run: true | ||
| github-token: '' | ||
| - name: Fail if not publishable | ||
| if: steps.publish.outputs.is-publishable != 'true' | ||
| run: | | ||
| echo "::error::Version in elm.json is already published or invalid. Run 'elm bump' to update it." | ||
| exit 1 | ||
| shell: bash | ||