Skip to content

ASTDiff Bot

ASTDiff Bot #25

Workflow file for this run

name: ASTDiff Bot
on:
issue_comment:
types: [created]
jobs:
diff:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
# Step 1: Check for @diff trigger and get the URL command
- name: Check for @diff trigger
id: check_diff
uses: actions/github-script@v6
with:
script: |
const commentBody = context.payload.comment.body;
const regex = /@diff\s+(\S+)/; // Match the next non-whitespace string after @diff
const match = commentBody.match(regex);
if (match) {
core.setOutput('triggered', 'true');
core.setOutput('url', match[1].trim()); // Capture the URL-like string
} else {
core.setOutput('triggered', 'false');
}
# Step 2: Run RefactoringMiner Docker image
- name: Run RefactoringMiner Docker image
if: ${{ steps.check_diff.outputs.triggered == 'true' }}
run: |
# Pull the Docker image and run it with port forwarding
docker pull tsantalis/refactoringminer
container_id=$(docker run -d -e OAuthToken=${{ secrets.OAUTH_TOKEN }} -p 6789:6789 tsantalis/refactoringminer diff --url "${{ steps.check_diff.outputs.url }}")
# Wait for the container to start and output logs
docker logs -f $container_id
# Step 2: Expose Docker container via ngrok (only if triggered)
- name: Expose Docker container via ngrok
id: expose_ngrok
if: ${{ steps.check_diff.outputs.triggered == 'true' }}
uses: LuisBoto/ngrok-tunnel-action@v0.1.7.2
with:
timeout: 1h
port: 6789
ngrok_authtoken : ${{ secrets.NGROK }} # Your ngrok auth token stored in GitHub Secrets
tunnel_type: http
# Step 5: Reply with the ngrok URL
- name: Reply with ngrok URL
if: ${{ steps.check_diff.outputs.triggered == 'true' }}
uses: actions/github-script@v7
with:
script: |
const url = '${{ steps.check_diff.outputs.url }}';
const ngrok_url = '${{ steps.ngrok_url.outputs.tunnel-url }}';
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `👋 You triggered the bot with the URL: \`${url}\`. The diff is being processed at: ${ngrok_url}`
})