Initial commit: GitHub TypeScript composite action #1
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: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| lint: | |
| name: Lint | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup pnpm | |
| uses: pnpm/action-setup@v4 | |
| with: | |
| version: 10 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 22 | |
| cache: pnpm | |
| - name: Install dependencies | |
| run: pnpm install | |
| - name: Run Biome | |
| run: pnpm run check | |
| test-action: | |
| name: Test Action | |
| runs-on: ubuntu-latest | |
| needs: lint | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Create test script | |
| run: | | |
| mkdir -p .github/scripts | |
| cat > .github/scripts/test.ts << 'EOF' | |
| export default async function run({ core, context, args }) { | |
| core.info('Test script running!'); | |
| core.info(`Context: ${context.eventName}`); | |
| core.info(`Args: ${JSON.stringify(args)}`); | |
| return { | |
| success: true, | |
| eventName: context.eventName, | |
| args | |
| }; | |
| } | |
| EOF | |
| - name: Test the action | |
| id: test | |
| uses: ./ | |
| with: | |
| ts-file: .github/scripts/test.ts | |
| args: '{"message":"Hello from test!","timestamp":"${{ github.event.head_commit.timestamp || github.run_id }}"}' | |
| - name: Verify result | |
| run: | | |
| echo "Action result: ${{ steps.test.outputs.result }}" | |
| # Parse and verify the JSON result contains expected fields | |
| echo '${{ steps.test.outputs.result }}' | jq -e '.success == true' | |
| echo '${{ steps.test.outputs.result }}' | jq -e '.eventName' | |
| echo '${{ steps.test.outputs.result }}' | jq -e '.args.message == "Hello from test!"' |