Add athena book #5
Workflow file for this run
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: Book Preview Link | |
on: | |
pull_request: | |
types: [opened, synchronize, reopened] | |
jobs: | |
preview-link: | |
runs-on: ubuntu-latest | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Add Preview Link | |
uses: actions/github-script@v6 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const previewUrl = `https://www.athenavm.org/book/preview/${context.issue.number}/`; | |
const commentBody = `📘 Book preview available at: ${previewUrl}`; | |
// Get all comments | |
const comments = await github.rest.issues.listComments({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo | |
}); | |
// Find our bot comment | |
const botComment = comments.data.find(comment => | |
comment.user.type === 'Bot' && comment.body.includes('Book preview available at:') | |
); | |
if (!botComment) { | |
// Create new comment | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: commentBody | |
}); | |
} |