Skip to content

Commit

Permalink
Merge pull request #80 from WORD-COINS/split_ci_files
Browse files Browse the repository at this point in the history
CIの整理
  • Loading branch information
puripuri2100 authored Oct 11, 2023
2 parents 5e70c6a + 14ac28a commit 4eae01d
Show file tree
Hide file tree
Showing 3 changed files with 77 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
name: CI
name: Articles Branch CI

on:
push:
branches:
- master
- "articles/**"
pull_request:
branches:
- master
- "articles/**"

jobs:
Expand All @@ -31,12 +29,6 @@ jobs:
run: echo "branch=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT
id: extract_branch

- name: build master branch
if: steps.extract_branch.outputs.branch == 'master'
run: |
WORD_FONT=sourcehan-jp make
aws s3 --endpoint-url=https://minio.k8s.word-ac.net cp ./main.pdf s3://article-bucket/$REPO_NAME.pdf
- name: check branch name
shell: bash
run: |
Expand Down Expand Up @@ -67,8 +59,22 @@ jobs:
if: steps.branch_regex.outputs.match == 'true'
run: |
ARTICLE_NAME=$(echo '${{ steps.extract_branch.outputs.branch }}' | awk -F '/' '{print $2}')
echo "article_name=$ARTICLE_NAME" >> $GITHUB_OUTPUT
cd ${{ steps.extract_branch.outputs.branch }}
WORD_FONT=sourcehan-jp make
id: build

- name: upload artifact to github
uses: actions/upload-artifact@v3
with:
name: ${{ steps.build.outputs.article_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
Expand Down
60 changes: 60 additions & 0 deletions .github/workflows/master_branch_ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Master Branch CI

on:
push:
branches:
- master
pull_request:
branches:
- master

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

# 事前にarticlesフォルダ内のmarkdownファイルに対してpandocを実行する
- name: convert markdown to latex
run: |
for filepath in $PWD/articles/*; do
cd $filepath
if [ -f ./main.md ]; then
if [ ! -f ./main.tex ]; then
echo $filepath
make pandoc
fi
fi
done
- name: build master branch
run: |
WORD_FONT=sourcehan-jp make
- name: upload artifact to github
uses: actions/upload-artifact@v3
with:
name: main.pdf
path: main.pdf
retention-days: 3 # 3日くらいあったらみんなダウンロードして確認しているはず

- name: upload artifact to k8s
continue-on-error: true # アップロードに失敗しても良い
run: |
aws s3 --endpoint-url=https://minio.k8s.word-ac.net cp ./main.pdf s3://article-bucket/$REPO_NAME.pdf
- name: Notify Slack
if: always()
run: ./scripts/notify_slack.sh
env:
status: ${{ job.status }}
2 changes: 2 additions & 0 deletions main.tex
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@
\pagestyle{fancy}
% 記事(サンプル)
\article{./articles/hinagata}
% 記事(markdownサンプル)
\article{./articles/hinagata-markdown}
% 編集後記用プレースホルダ
\phantomsection
\addcontentsline{toc}{chapter}{編集後記}
Expand Down

0 comments on commit 4eae01d

Please sign in to comment.