Skip to content

Commit 5952acd

Browse files
authored
Add GitHub Actions workflow for Gmeek build and deploy
1 parent 5294d31 commit 5952acd

1 file changed

Lines changed: 89 additions & 0 deletions

File tree

.github/workflows/Gmeek.yml

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
name: build Gmeek
2+
3+
on:
4+
workflow_dispatch:
5+
issues:
6+
types: [opened, edited]
7+
schedule:
8+
- cron: "0 16 * * *"
9+
10+
jobs:
11+
build:
12+
name: Generate blog
13+
runs-on: ubuntu-24.04
14+
if: ${{ github.event.repository.owner.id == github.event.sender.id || github.event_name == 'schedule' }}
15+
permissions: write-all
16+
steps:
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- name: Setup Pages
21+
id: pages
22+
uses: actions/configure-pages@v4
23+
24+
- name: Get config.json
25+
run: |
26+
echo "====== check config.josn file ======"
27+
cat config.json
28+
echo "====== check config.josn end ======"
29+
sudo apt-get install jq
30+
31+
- name: Set up Python
32+
uses: actions/setup-python@v5
33+
with:
34+
python-version: 3.8
35+
36+
- name: Clone source code
37+
run: |
38+
GMEEK_VERSION=$(jq -r ".GMEEK_VERSION" config.json)
39+
git clone https://github.com/Meekdai/Gmeek.git /opt/Gmeek;
40+
cd /opt/Gmeek/
41+
lastTag=$(git describe --tags `git rev-list --tags --max-count=1`)
42+
if [ $GMEEK_VERSION == 'last' ]; then git checkout $lastTag; else git checkout $GMEEK_VERSION; fi;
43+
44+
- name: Install dependencies
45+
run: |
46+
pip install --upgrade pip
47+
pip install -r /opt/Gmeek/requirements.txt
48+
49+
- name: Generate new html
50+
run: |
51+
cp -r ./* /opt/Gmeek/
52+
cd /opt/Gmeek/
53+
python Gmeek.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} --issue_number '${{ github.event.issue.number }}'
54+
cp -a /opt/Gmeek/docs ${{ github.workspace }}
55+
cp -a /opt/Gmeek/backup ${{ github.workspace }}
56+
cp /opt/Gmeek/blogBase.json ${{ github.workspace }}
57+
58+
- name: update html
59+
run: |
60+
git config --local user.email "$(jq -r ".email" config.json)"
61+
git config --local user.name "${{ github.repository_owner }}"
62+
git add .
63+
git commit -a -m '🎉auto update by Gmeek action' || echo "nothing to commit"
64+
git push || echo "nothing to push"
65+
sleep 3
66+
67+
- name: Upload artifact
68+
uses: actions/upload-pages-artifact@v3
69+
with:
70+
path: 'docs/.'
71+
72+
deploy:
73+
name: Deploy blog
74+
runs-on: ubuntu-24.04
75+
needs: build
76+
permissions:
77+
contents: write
78+
pages: write
79+
id-token: write
80+
concurrency:
81+
group: "pages"
82+
cancel-in-progress: false
83+
environment:
84+
name: github-pages
85+
url: ${{ steps.deployment.outputs.page_url }}
86+
steps:
87+
- name: Deploy to GitHub Pages
88+
id: deployment
89+
uses: actions/deploy-pages@v4

0 commit comments

Comments
 (0)