generated from devcontainers/feature-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
67 lines (57 loc) · 2 KB
/
update-documentation.yaml
File metadata and controls
67 lines (57 loc) · 2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
name: "Update Documentation"
on:
push:
branches:
- main
workflow_dispatch:
jobs:
generate:
runs-on: ubuntu-latest
environment: documentation
permissions:
contents: write
pull-requests: write
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- name: Generate Documentation
uses: devcontainers/action@v1
with:
generate-docs: "true"
base-path-to-features: "./src"
- name: Create a PR for Documentation
id: push_image_info
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -e
echo "Start."
# Configure git and Push updates
git config --global user.email github-actions[bot]@users.noreply.github.com
git config --global user.name github-actions[bot]
git config pull.rebase false
branch=automated-documentation-update-$GITHUB_RUN_ID
git checkout -b $branch
message='📝 docs: automated update of feature READMEs [skip ci]'
# Add / update and commit
git add */**/README.md
git commit -m "$message" || export NO_UPDATES=true
# Push
if [ "$NO_UPDATES" != "true" ] ; then
git push origin "$branch"
gh pr create --title "$message" --body "$message"
fi
- name: Automatically Merge PR
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
# Wait briefly to ensure the PR is created
sleep 10
# Find the PR created by the previous step
pr_number=$(gh pr list --head automated-documentation-update-$GITHUB_RUN_ID --limit 1 --json number --jq '.[0].number')
if [ -n "$pr_number" ]; then
# Merge the PR
gh pr merge $pr_number --auto --squash --delete-branch --subject "📝 docs: automated update of feature READMEs [skip ci]"
else
echo "No Pull Request found to merge."
fi