文字列に半角スペースなどが含まれていると処理に失敗する #110
This file contains 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: Run free test | |
on: | |
issue_comment: | |
types: [ created ] | |
jobs: | |
run_free_test: | |
if: github.event.issue.pull_request == null && startsWith(github.event.comment.body, '```text:freetest') && github.event.comment.user.login == 'YuukiToriyama' | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Get head commit | |
uses: actions/github-script@v7.0.1 | |
id: get-head-commit | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
result-encoding: string | |
script: | | |
const commit = await github.rest.git.getRef({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
ref: "heads/main" | |
}) | |
return commit.data.object.sha | |
- name: Install wasm-pack | |
working-directory: wasm | |
run: curl https://rustwasm.github.io/wasm-pack/installer/init.sh -sSf | sh | |
- name: Build wasm module | |
working-directory: wasm | |
run: wasm-pack build --target nodejs --scope toriyama | |
- name: Setup Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: 20 | |
- name: Run free test | |
id: run-free-test | |
continue-on-error: true | |
run: echo '${{ github.event.comment.body }}' | grep -v '```' | node .github/scripts/free_test.js | |
- name: Read test result | |
id: read-test-result | |
uses: juliangruber/read-file-action@v1.1.7 | |
with: | |
path: ./test_result.md | |
- name: Comment | |
uses: actions/github-script@v7.0.1 | |
if: steps.run-free-test.outcome == 'success' | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: `${{ steps.read-test-result.outputs.content }}\n### テストに使用したリビジョン\n${{ steps.get-head-commit.outputs.result }}` | |
}) | |
await github.rest.reactions.createForIssueComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: ${{ github.event.comment.id }}, | |
content: "rocket" | |
}) | |
- name: Comment(on error) | |
uses: actions/github-script@v7.0.1 | |
if: steps.run-free-test.outcome == 'failure' | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
await github.rest.issues.createComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
issue_number: context.issue.number, | |
body: `:bomb: テストが失敗しました\n\n${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}` | |
}) | |
await github.rest.reactions.createForIssueComment({ | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
comment_id: ${{ github.event.comment.id }}, | |
content: "eyes" | |
}) |