Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add push_path argument #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,12 @@ This action compiles latex/xelatex files using [Tectonic](https://tectonic-types

**Optional** Compiled PDF is pushed, if `push` is passed as 'yes'.

### `push_path`

**Optional** Path to push compiled PDF to, if defined.

## Outputs
Pushes a Compiled PDF file parallel to the tex, xtx file, if push is passed as 'yes'.
Pushes a Compiled PDF file parallel to the tex, xtx file, if push is passed as 'yes' and push_path is undefined. Otherwise a Compiled PDF file will be pushed to the location defined in push_path, if push is passed as 'yes'.

## Example usage

Expand All @@ -34,6 +38,7 @@ jobs:
with:
tex_path: 'dir/file.tex'
push: 'yes'
push_path: 'output_dir'
```

### Doesn't Push Compiled PDF
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,13 @@ inputs:
description: 'String stating whether to push output PDF, PDF will only be pushed in case of "yes"'
default: 'no'
required: false
push_path:
description: 'Path of output PDF, PDF will be pushed to same directory as Tex File if unused'
required: false
runs:
using: 'docker'
image: 'Dockerfile'
args:
- ${{ inputs.tex_path }}
- ${{ inputs.push }}
- ${{ inputs.push_path }}
16 changes: 13 additions & 3 deletions entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ fi

FILE_NAME=$(basename $OUTPUT_PDF)
DIR=$(dirname $OUTPUT_PDF)
OUTPUT_PATH=$OUTPUT_PDF

PUSH_PATH=$3
if [[ ! -z $PUSH_PATH ]]; then
if [[ ${PUSH_PATH:0:1} == "/" ]]; then
PUSH_PATH=${PUSH_PATH:1}
fi
DIR=$PUSH_PATH
OUTPUT_PATH="$DIR/$FILE_NAME"
fi

STATUSCODE=$(curl --silent --output resp.json --write-out "%{http_code}" -X GET -H "Authorization: token $GITHUB_TOKEN" https://api.github.com/repos/${GITHUB_REPOSITORY}/contents/$DIR)

Expand All @@ -34,11 +44,11 @@ do
if [ "$NAME" = "$FILE_NAME" ]; then
SHA=$(echo $i | jq -r .sha)
break
fi
fi
done

echo '{
"message": "'"update $OUTPUT_PDF"'",
"message": "'"update $OUTPUT_PATH"'",
"committer": {
"name": "Tectonic Action",
"email": "tectonic-action@github.com"
Expand All @@ -49,7 +59,7 @@ echo '{

STATUSCODE=$(curl --silent --output /dev/stderr --write-out "%{http_code}" \
-i -X PUT -H "Authorization: token $GITHUB_TOKEN" -d @payload.json \
https://api.github.com/repos/${GITHUB_REPOSITORY}/contents/${OUTPUT_PDF})
https://api.github.com/repos/${GITHUB_REPOSITORY}/contents/${OUTPUT_PATH})

if [ $((STATUSCODE/100)) -ne 2 ]; then
echo "Github's API returned $STATUSCODE"
Expand Down