Transformation of Word Specification #8
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: Word to AsciiDoc Transformation | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
transform: | |
# if: contains(github.event.issue.labels.*.name, 'transformation-request') | |
runs-on: ubuntu-latest | |
steps: | |
- name: Comment on Issue | |
uses: actions/github-script@v5 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const artifact_url = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `🚀 Transformation initiated! Once complete, the bot will comment with a link to the converted files.` | |
}); | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Install dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y pandoc jq wget | |
- name: Extract file URL and download Word file | |
env: | |
ISSUE_BODY: ${{ github.event.issue.body }} | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
run: | | |
FILE_URL=$(echo "$ISSUE_BODY" | grep -oP 'https?://[^ ]+\.docx') | |
wget "$FILE_URL" -O input_file.docx | |
- name: Create output folder | |
run: | | |
mkdir -p output_folder | |
- name: Transform Word to AsciiDoc | |
run: | | |
pandoc input_file.docx -f docx -t asciidoctor --wrap=none --extract-media=output_folder -o output_folder/generated_file.adoc | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install word2asciidoc and fix AsciiDoc | |
run: | | |
pip install git+https://github.com/admin-shell-io/word2asciidoc.git@master | |
fix_adoc --adoc_input output_folder/generated_file.adoc --adoc_output output_folder/index.adoc | |
- name: Upload artifact | |
uses: actions/upload-artifact@v2 | |
with: | |
name: converted-docs | |
path: output_folder | |
- name: Comment on Issue | |
uses: actions/github-script@v5 | |
with: | |
github-token: ${{secrets.GITHUB_TOKEN}} | |
script: | | |
const artifact_url = `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`; | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `🚀 The transformation is complete! You can download the AsciiDoc files under **Artifacts** [here](${artifact_url}).` | |
}); |