test #18
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: Distribute Articles | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
distribute: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout main repository | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Set up Node.js | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '22.11.0' | |
- name: Install dependencies | |
run: npm install gray-matter fs-extra | |
- name: Update local_updated_at in articles | |
run: | | |
node scripts/update_metadata.js articles/share | |
- name: Checkout from Qiita repository | |
uses: actions/checkout@v4 | |
with: | |
repository: solitudeRA/qiita-repo | |
ref: main | |
token: ${{ secrets.BLOG_PROJECT_TOKEN }} | |
path: qiita-repo | |
- name: Ensure qiita-repo/pre-publish directory exists | |
run: | | |
mkdir -p qiita-repo/pre-publish | |
- name: Push to Qiita repository | |
run: | | |
rm -rf qiita-repo/pre-publish/* | |
cp -r articles/share/* qiita-repo/pre-publish/ | |
if [ -d articles/qiita ] && [ "$(ls -A articles/qiita)" ]; then | |
cp -r articles/qiita/* qiita-repo/pre-publish/ | |
else | |
echo "Directory articles/qiita does not exist or is empty. Skipping copy step." | |
fi | |
cd qiita-repo/pre-publish/ | |
git config --local user.name "SolitudeRA" | |
git config --local user.email "solitude@protogalaxy.me" | |
git add . | |
git commit -m "Update pre-publish articles for Qiita from main-repo" | |
git push | |
- name: Checkout from Zenn repository | |
uses: actions/checkout@v4 | |
with: | |
repository: SolitudeRA/zenn-repo | |
ref: main | |
token: ${{ secrets.BLOG_PROJECT_TOKEN }} | |
path: zenn-repo | |
- name: Ensure zenn-repo/pre-publish directory exists | |
run: | | |
mkdir -p zenn-repo/pre-publish | |
- name: Push to Zenn repository | |
run: | | |
rm -rf zenn-repo/pre-publish/* | |
cp -r articles/share/* zenn-repo/pre-publish/ | |
if [ -d articles/zenn ] && [ "$(ls -A articles/zenn)" ]; then | |
cp -r articles/zenn/* zenn-repo/pre-publish/ | |
else | |
echo "Directory articles/zenn does not exist or is empty. Skipping copy step." | |
fi | |
cd zenn-repo/pre-publish/ | |
git config --local user.name "SolitudeRA" | |
git config --local user.email "solitude@protogalaxy.me" | |
git add . | |
git commit -m "Update pre-publish articles for Zenn from main-repo" | |
git push |