52 lines
2.1 KiB
YAML
52 lines
2.1 KiB
YAML
# .github/workflows/issues2md.yml
|
|
# https://github.com/mattduck/gh2md/issues/11
|
|
|
|
name: Issues2Markdown
|
|
on:
|
|
push: # comment it to reduce update.
|
|
schedule:
|
|
# every day
|
|
#- cron: "0 0 * * *"
|
|
# every hour
|
|
- cron: "16 * * * *"
|
|
jobs:
|
|
build:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@master
|
|
with:
|
|
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of your personal token
|
|
fetch-depth: 0 # otherwise, you will failed to push refs to dest repo
|
|
- name: Backup github issues to a markdown file.
|
|
run: |
|
|
set -x
|
|
pip3 install --user --upgrade setuptools
|
|
pip3 install --user gh2md
|
|
export PATH="$HOME/.local/bin:$PATH"
|
|
export GITHUB_ACCESS_TOKEN=${{ secrets.GITHUB_TOKEN }}
|
|
# fix: RuntimeError: Output directory already exists and has files in it
|
|
git rm -rf archive/github/issues/
|
|
# workaround for https://github.com/mattduck/gh2md/pull/31
|
|
mkdir -p archive/github/issues/ || true
|
|
gh2md $GITHUB_REPOSITORY archive/github/issues/ --idempotent --multiple-files --file-extension .ghmd
|
|
echo "converting github markdown to strict markdown"
|
|
sudo apt-get install pandoc
|
|
find archive/github/issues/ -name '*.ghmd' -type f | while read f; do b="${f%.*}"; pandoc --verbose -f gfm+hard_line_breaks -t markdown_strict "$b.ghmd" -o "$b.md"; done
|
|
# cleanup: move .ghmd files to separate folder
|
|
mkdir -p archive/github/issues/ghmd/
|
|
mv -v archive/github/issues/*.ghmd archive/github/issues/ghmd/
|
|
git add archive/github/issues/
|
|
- name: Commit files
|
|
run: |
|
|
git config --local user.email "action@github.com"
|
|
git config --local user.name "GitHub Action"
|
|
git commit -m "up archive/github/issues/" -a
|
|
- name: Extract branch name
|
|
shell: bash
|
|
run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})"
|
|
id: extract_branch
|
|
- name: Push changes
|
|
uses: ad-m/github-push-action@master
|
|
with:
|
|
github_token: ${{ secrets.GITHUB_TOKEN }}
|
|
branch: ${{ steps.extract_branch.outputs.branch }}
|