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: Articles Branch CI | |
on: | |
push: | |
branches: | |
- "articles/**" | |
pull_request: | |
branches: | |
- "articles/**" | |
jobs: | |
build-article: | |
runs-on: ubuntu-20.04 | |
container: | |
image: ghcr.io/word-coins/latex-build:latest | |
env: | |
AWS_ACCESS_KEY_ID: ${{ secrets.MINIO_ACCESS_KEY }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.MINIO_SECRET_KEY }} | |
AWS_EC2_METADATA_DISABLED: true | |
PDF_BUILD_NOTIFY_URL: ${{ secrets.PDF_BUILD_NOTIFY_URL }} | |
REPO_NAME: ${{ github.repository }} | |
RUN_ID: ${{ github.run_id }} | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: extract branch name | |
shell: bash | |
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
id: extract_branch | |
- name: check branch name | |
shell: bash | |
run: | | |
if [[ ${{ steps.extract_branch.outputs.branch }} =~ ^articles/.*$ ]]; then | |
echo "match=true" >> $GITHUB_OUTPUT | |
echo "name=${GITHUB_REF#refs/heads/articles/}" >> $GITHUB_OUTPUT | |
fi | |
id: branch_regex | |
- name: check exist main.md file | |
if: steps.branch_regex.outputs.match == 'true' | |
shell: bash | |
run: | | |
cd ${{ steps.extract_branch.outputs.branch }} | |
if [ -f ./main.md ]; then | |
if [ ! -f ./main.tex ]; then | |
echo "exist=true" >> $GITHUB_OUTPUT | |
fi | |
fi | |
id: main_md | |
- name: convert markdown to latex | |
if: steps.main_md.outputs.exist == 'true' | |
run: | | |
cd ${{ steps.extract_branch.outputs.branch }} | |
make pandoc | |
- name: build articles branch | |
if: steps.branch_regex.outputs.match == 'true' | |
run: | | |
ARTICLE_NAME=$(echo '${{ steps.extract_branch.outputs.branch }}' | awk -F '/' '{print $2}') | |
cd ${{ steps.extract_branch.outputs.branch }} | |
WORD_FONT=sourcehan-jp make | |
- name: upload artifact to github | |
uses: actions/upload-artifact@v3 | |
with: | |
name: ${{ steps.extract_branch.outputs.name }}.pdf | |
path: ${{ steps.extract_branch.outputs.branch }}/main.pdf | |
retention-days: 3 # 3日くらいあったらみんなダウンロードして確認しているはず | |
- name: upload artifact to k8s | |
continue-on-error: true # 失敗しても良い | |
if: steps.branch_regex.outputs.match == 'true' | |
run: | | |
aws s3 --endpoint-url=https://minio.k8s.word-ac.net cp ./main.pdf s3://article-bucket/$REPO_NAME-$ARTICLE_NAME.pdf | |
- name: Notify Slack | |
if: always() | |
run: ./scripts/notify_slack.sh | |
env: | |
status: ${{ job.status }} |