test: test github-action #118
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: Release | |
| on: | |
| push: | |
| branches: | |
| - release | |
| workflow_dispatch: | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '20.x' | |
| registry-url: 'https://registry.npmjs.org' | |
| - name: Install pnpm | |
| uses: pnpm/action-setup@v4 | |
| - name: Cache | |
| id: cache-dependencies | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| **/node_modules | |
| key: ${{ runner.OS }}-${{ hashFiles('**/pnpm-lock.yaml') }} | |
| - name: Installing Dependencies | |
| if: steps.cache-dependencies.outputs.cache-hit != 'true' | |
| run: pnpm install | |
| - name: Running Test | |
| run: pnpm run test | |
| - name: Running Build | |
| run: pnpm run build | |
| - name: Check if GHP_TOKEN is Set and Valid | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GHP_TOKEN }} | |
| run: | | |
| if [ -z "$GITHUB_TOKEN" ]; then | |
| echo "❌ GHP_TOKEN is not set!" | |
| exit 1 | |
| fi | |
| echo "✅ GHP_TOKEN is set. Testing against GitHub API..." | |
| curl -s -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/user | jq . | |
| if [ $? -ne 0 ]; then | |
| echo "❌ Failed to access GitHub API with GHP_TOKEN" | |
| exit 1 | |
| else | |
| echo "✅ Successfully accessed GitHub API with GHP_TOKEN" | |
| fi | |
| - name: Create Release Pull Request or Publish | |
| id: changesets | |
| uses: changesets/action@v1 | |
| with: | |
| version: pnpm changeset version | |
| publish: pnpm changeset publish | |
| commit: 'chore(release): changesets versioning & publish' | |
| title: 'Changesets: versioning & publish' | |
| env: | |
| GITHUB_TOKEN: ${{ secrets.GHP_TOKEN }} | |
| NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} |