harupy / comment-on-pr Goto Github PK
View Code? Open in Web Editor NEWA GitHub action to add a comment on pull requests.
A GitHub action to add a comment on pull requests.
It would be great if it was possible to include (in particular image) artefacts in the PR comment. I could not see this feature documented though... Thanks for this...
Accessing files in the root directory leads to a 403 forbidden from github
test
I'm wondering if the template is able to interpolate custom variables.
Hi, love the work you've done with this tool, but I was wondering if there was a way to make it add a comment only when I add a specific label to the PR, and if I could have it comment different things depending on the label that I add.
Thanks! :)
Hi, I'm looking to add an action to a private repository of mine where the word count of the main document is commented when a PR is opened.
I have two components: (1) wordcount.py
(below) takes the main.tex
file, summarises the word count and writes it to file at (2) .github/workflows/wordcount.md
.
# wordcount.py
import os
import subprocess
def main():
""" Save the output of texcount to file and then trim it. """
with open(".github/workflows/wordcount.md", "w") as f:
f.write("The current word count is:\n")
f.write("==========================\n\n")
cmd = "texcount -inc -nosub main.tex"
string = str(subprocess.check_output(cmd, shell=True))
items = string.split("\\n\\n")
block = items[-2]
for line in block.split("\\n")[2:]:
f.write(line + "\n")
if __name__ == "__main__":
main()
My action file .github/workflows/wordcount.yml
looks like this then:
name: Comment word count
on: pull_request
jobs:
build:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.7]
steps:
- uses: actions/checkout@v1
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install LaTeX
run: |
sudo apt-get update
sudo apt-get install -y texlive-extra-utils
- name: Clone submodules
run: git submodule update --init --recursive
- name: Calculate wordcount
run: python wordcount.py
- name: Comment word count
uses: harupy/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
template: wordcount.md
However, when the action runs on GitHub I get the error below and I have no idea why. Would you be able to shed some light on this at all?
with:
template: wordcount.md
env:
pythonLocation: /opt/hostedtoolcache/Python/3.7.6/x64
GITHUB_TOKEN: ************
/usr/bin/docker run --name f64d7289f5ffc4be04e629a4bd1a214c5ca80_982401 \
--label 1f64d7 --workdir /github/workspace --rm -e pythonLocation -e GITHUB_TOKEN \
-e INPUT_TEMPLATE -e INPUT_DOMAIN -e HOME -e GITHUB_REF -e GITHUB_SHA \
-e GITHUB_REPOSITORY -e GITHUB_RUN_ID -e GITHUB_RUN_NUMBER -e GITHUB_ACTOR \
-e GITHUB_WORKFLOW -e GITHUB_HEAD_REF -e GITHUB_BASE_REF \
-e GITHUB_EVENT_NAME -e GITHUB_WORKSPACE -e GITHUB_ACTION \
-e GITHUB_EVENT_PATH -e RUNNER_OS -e RUNNER_TOOL_CACHE -e RUNNER_TEMP \
-e RUNNER_WORKSPACE -e ACTIONS_RUNTIME_URL -e ACTIONS_RUNTIME_TOKEN \
-e GITHUB_ACTIONS=true -v "/var/run/docker.sock":"/var/run/docker.sock" \
-v "/home/runner/work/_temp/_github_home":"/github/home" \
-v "/home/runner/work/_temp/_github_workflow":"/github/workflow" \
-v "/home/runner/work/thesis/thesis":"/github/workspace" 1f64d7:289f5ffc4be04e629a4bd1a214c5ca80
python: can't open file 'entrypoint.py': [Errno 2] No such file or directory
In your example:
steps:
- uses: actions/checkout@master
- uses: harupy/comment-on-pr@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
filename: template.md
Does the step actions/checkout@master
is really necessary for add a comment on a PR ?
Pipeline would be slightly faster without checkout step.
Hi ! I am willing to create a fork from your repos, but I dismissed it as soon as I saw that there is no Licence file. Could you add one ?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.