Add explicit permissions to GitHub Actions workflows

This commit is contained in:
2025-04-18 14:43:19 +01:00
parent bfac63799b
commit 2f4d88f8dd
2 changed files with 12 additions and 8 deletions

View File

@@ -10,6 +10,8 @@ jobs:
build: build:
name: Build and Release name: Build and Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: write
steps: steps:
- name: Checkout code - name: Checkout code
uses: actions/checkout@v3 uses: actions/checkout@v3
@@ -60,7 +62,7 @@ jobs:
prerelease: false prerelease: false
body: | body: |
Release of version ${{ env.VERSION }} Release of version ${{ env.VERSION }}
See [CHANGELOG.md](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/blob/main/CHANGELOG.md) for details. See [CHANGELOG.md](https://github.com/wpallstars/wp-plugin-starter-template-for-ai-coding/blob/main/CHANGELOG.md) for details.
env: env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

View File

@@ -11,6 +11,8 @@ jobs:
sync-wiki: sync-wiki:
name: Sync Wiki to GitHub name: Sync Wiki to GitHub
runs-on: ubuntu-latest runs-on: ubuntu-latest
permissions:
contents: write
steps: steps:
- name: Checkout source code - name: Checkout source code
uses: actions/checkout@v3 uses: actions/checkout@v3
@@ -23,29 +25,29 @@ jobs:
- name: Clone wiki repository - name: Clone wiki repository
run: | run: |
git clone https://github.com/${{ github.repository }}.wiki.git wiki git clone https://github.com/${{ github.repository }}.wiki.git wiki
- name: Sync wiki content - name: Sync wiki content
run: | run: |
# Remove all files from wiki repository except .git # Remove all files from wiki repository except .git
find wiki -mindepth 1 -maxdepth 1 -not -name '.git' -exec rm -rf {} \; find wiki -mindepth 1 -maxdepth 1 -not -name '.git' -exec rm -rf {} \;
# Copy .wiki content to wiki repository # Copy .wiki content to wiki repository
cp -r .wiki/* wiki/ cp -r .wiki/* wiki/
# Go to wiki repository # Go to wiki repository
cd wiki cd wiki
# Add all changes # Add all changes
git add . git add .
# Check if there are changes to commit # Check if there are changes to commit
if git diff --staged --quiet; then if git diff --staged --quiet; then
echo "No changes to commit" echo "No changes to commit"
exit 0 exit 0
fi fi
# Commit changes # Commit changes
git commit -m "Sync wiki from source repository" git commit -m "Sync wiki from source repository"
# Push changes # Push changes
git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git git push https://${{ github.actor }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.wiki.git