mirror of https://github.com/Meekdai/Gmeek.git
Update static.yml
Fixed the issue when using organization by checking membership of the user in the org.
This commit is contained in:
parent
ac556c5cba
commit
b5da6fa2ca
|
|
@ -1,43 +1,124 @@
|
||||||
# Simple workflow for deploying static content to GitHub Pages
|
name: build Gmeek
|
||||||
name: Deploy static content to Pages
|
|
||||||
|
|
||||||
on:
|
on:
|
||||||
# Runs on pushes targeting the default branch
|
|
||||||
push:
|
|
||||||
branches: ["main"]
|
|
||||||
|
|
||||||
# Allows you to run this workflow manually from the Actions tab
|
|
||||||
workflow_dispatch:
|
workflow_dispatch:
|
||||||
|
issues:
|
||||||
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages
|
types: [opened, edited]
|
||||||
permissions:
|
schedule:
|
||||||
contents: read
|
- cron: "0 16 * * *"
|
||||||
pages: write
|
|
||||||
id-token: write
|
|
||||||
|
|
||||||
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
|
|
||||||
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
|
|
||||||
concurrency:
|
|
||||||
group: "pages"
|
|
||||||
cancel-in-progress: false
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
# Single deploy job since we're just deploying
|
|
||||||
deploy:
|
check-membership:
|
||||||
environment:
|
runs-on: ubuntu-20.04
|
||||||
name: github-pages
|
outputs:
|
||||||
url: ${{ steps.deployment.outputs.page_url }}
|
is_member: ${{ steps.check_membership.outputs.is_member }}
|
||||||
runs-on: ubuntu-latest
|
steps:
|
||||||
|
- name: Check if user is org member
|
||||||
|
id: check_membership
|
||||||
|
uses: actions/github-script@v6
|
||||||
|
env:
|
||||||
|
ORG_NAME: '${{ github.event.repository.owner.login }}'
|
||||||
|
USER_LOGIN: '${{ github.event.sender.login }}'
|
||||||
|
with:
|
||||||
|
script: |
|
||||||
|
console.log('Repository owner:', process.env.ORG_NAME);
|
||||||
|
console.log('User login:', process.env.USER_LOGIN);
|
||||||
|
console.log('Repository owner ID:', context.payload.repository.owner.id);
|
||||||
|
console.log('Sender ID:', context.payload.sender.id);
|
||||||
|
const org = process.env.ORG_NAME;
|
||||||
|
const username = process.env.USER_LOGIN;
|
||||||
|
try {
|
||||||
|
const response = await github.rest.orgs.checkMembershipForUser({
|
||||||
|
org: org,
|
||||||
|
username: username,
|
||||||
|
});
|
||||||
|
console.log('API Response:', response);
|
||||||
|
console.log(`User ${username} is a member of ${org}`);
|
||||||
|
core.setOutput('is_member', 'true');
|
||||||
|
} catch (error) {
|
||||||
|
console.log('Error details:', error);
|
||||||
|
console.log(`User ${username} is NOT a member of ${org}`);
|
||||||
|
core.setOutput('is_member', 'false');
|
||||||
|
}
|
||||||
|
|
||||||
|
build:
|
||||||
|
name: Generate blog
|
||||||
|
needs: check-membership
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
if: ${{ github.event.repository.owner.id == github.event.sender.id || needs.check-membership.outputs.is_member == 'true' || github.event_name == 'schedule' }}
|
||||||
|
permissions: write-all
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
- name: Setup Pages
|
- name: Setup Pages
|
||||||
uses: actions/configure-pages@v5
|
id: pages
|
||||||
|
uses: actions/configure-pages@v4
|
||||||
|
|
||||||
|
- name: Get config.json
|
||||||
|
run: |
|
||||||
|
echo "====== check config.josn file ======"
|
||||||
|
cat config.json
|
||||||
|
echo "====== check config.josn end ======"
|
||||||
|
sudo apt-get install jq
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: 3.8
|
||||||
|
|
||||||
|
- name: Clone source code
|
||||||
|
run: |
|
||||||
|
GMEEK_VERSION=$(jq -r ".GMEEK_VERSION" config.json)
|
||||||
|
git clone https://github.com/Meekdai/Gmeek.git /opt/Gmeek;
|
||||||
|
cd /opt/Gmeek/
|
||||||
|
lastTag=$(git describe --tags `git rev-list --tags --max-count=1`)
|
||||||
|
if [ $GMEEK_VERSION == 'last' ]; then git checkout $lastTag; else git checkout $GMEEK_VERSION; fi;
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
run: |
|
||||||
|
pip install --upgrade pip
|
||||||
|
pip install -r /opt/Gmeek/requirements.txt
|
||||||
|
|
||||||
|
- name: Generate new html
|
||||||
|
run: |
|
||||||
|
cp -r ./* /opt/Gmeek/
|
||||||
|
cd /opt/Gmeek/
|
||||||
|
python Gmeek.py ${{ secrets.GITHUB_TOKEN }} ${{ github.repository }} --issue_number '${{ github.event.issue.number }}'
|
||||||
|
cp -a /opt/Gmeek/docs ${{ github.workspace }}
|
||||||
|
cp -a /opt/Gmeek/backup ${{ github.workspace }}
|
||||||
|
cp /opt/Gmeek/blogBase.json ${{ github.workspace }}
|
||||||
|
|
||||||
|
- name: update html
|
||||||
|
run: |
|
||||||
|
git config --local user.email "$(jq -r ".email" config.json)"
|
||||||
|
git config --local user.name "${{ github.repository_owner }}"
|
||||||
|
git add .
|
||||||
|
git commit -a -m '🎉auto update by Gmeek action' || echo "nothing to commit"
|
||||||
|
git push || echo "nothing to push"
|
||||||
|
sleep 3
|
||||||
|
|
||||||
- name: Upload artifact
|
- name: Upload artifact
|
||||||
uses: actions/upload-pages-artifact@v3
|
uses: actions/upload-pages-artifact@v3
|
||||||
with:
|
with:
|
||||||
# Upload entire repository
|
path: 'docs/.'
|
||||||
path: '.'
|
|
||||||
|
deploy:
|
||||||
|
name: Deploy blog
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
needs: build
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
pages: write
|
||||||
|
id-token: write
|
||||||
|
concurrency:
|
||||||
|
group: "pages"
|
||||||
|
cancel-in-progress: false
|
||||||
|
environment:
|
||||||
|
name: github-pages
|
||||||
|
url: ${{ steps.deployment.outputs.page_url }}
|
||||||
|
steps:
|
||||||
- name: Deploy to GitHub Pages
|
- name: Deploy to GitHub Pages
|
||||||
id: deployment
|
id: deployment
|
||||||
uses: actions/deploy-pages@v4
|
uses: actions/deploy-pages@v4
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue