Skip to content

Commit 82b816a

Browse files
authored
Update update-documentation.yml
1 parent 2dee221 commit 82b816a

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

.github/workflows/update-documentation.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,74 @@
1+
You can update the `.github/workflows/update-documentation.yml` file with the following content to resolve the push rejection issue:
2+
3+
```yaml
14
name: "Update Documentation"
25
on:
36
push:
47
branches:
58
- main
69
workflow_dispatch:
710
11+
jobs:
12+
generate:
13+
runs-on: ubuntu-latest
14+
environment: documentation
15+
permissions:
16+
contents: write
17+
pull-requests: write
18+
if: "github.ref == 'refs/heads/main'"
19+
steps:
20+
- uses: actions/checkout@v4
21+
22+
- name: Generate Documentation
23+
uses: devcontainers/action@v1
24+
with:
25+
generate-docs: "true"
26+
base-path-to-features: "./src"
27+
28+
- name: Create a PR for Documentation
29+
id: push_image_info
30+
env:
31+
GITHUB_TOKEN: ${{ secrets.PAT }}
32+
run: |
33+
set -e
34+
echo "Start."
35+
36+
# Configure git and Pull latest changes
37+
git config --global user.email github-actions@github.com
38+
git config --global user.name github-actions
39+
git config pull.rebase false
40+
41+
git pull origin main
42+
43+
branch=automated-documentation-update-$GITHUB_RUN_ID
44+
git checkout -b $branch
45+
message='Automated documentation update'
46+
47+
# Add / update and commit
48+
git add */**/README.md
49+
git commit -m 'Automated documentation update [skip ci]' || export NO_UPDATES=true
50+
51+
# Push
52+
if [ "$NO_UPDATES" != "true" ] ; then
53+
git push origin "$branch"
54+
gh api \
55+
--method POST \
56+
-H "Accept: application/vnd.github+json" \
57+
/repos/${GITHUB_REPOSITORY}/pulls \
58+
-f title="$message" \
59+
-f body="$message" \
60+
-f head="$branch" \
61+
-f base='main'
62+
fi
63+
```
64+
65+
This ensures the workflow pulls the latest changes from the main branch before creating a new branch and pushing the updates.name: "Update Documentation"
66+
on:
67+
push:
68+
branches:
69+
- main
70+
workflow_dispatch:
71+
872
jobs:
973
generate:
1074
runs-on: ubuntu-latest

0 commit comments

Comments
 (0)