-
Notifications
You must be signed in to change notification settings - Fork 178
63 lines (52 loc) · 2.17 KB
/
auto-sync-gh-pages.yml
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
name: Sync update to gh-pages branch
on:
push:
# Sequence of patterns matched against refs/tags
tags:
- 'v*' # Push events to matching v*, i.e. v1.0, v20.15.10
workflow_dispatch: # Use for manaully trigger to debug
permissions:
contents: write # Allow to create a release.
jobs:
sync-changes-to-gh-pages-branch:
runs-on: ubuntu-latest
steps:
# This step uses Github's checkout-action: https://github.com/actions/checkout
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
# Configure Git for helm release
- name: Configure Git
run: |
git config user.name "$GITHUB_ACTOR"
git config user.email "$GITHUB_ACTOR@users.noreply.github.com"
- name: Check Latest Release Tag
id: check
run: |
git fetch --tags --force
latest_tag=$(git tag --sort=-creatordate | head -n 1)
echo "latest_tag=${latest_tag}" >> $GITHUB_OUTPUT
./hack/match-release-tag.sh ${latest_tag}
valid_tag=$?
current_branch=$(git rev-parse --abbrev-ref HEAD)
if [[ "${current_branch}" == "master" && "${valid_tag}" == 0 ]]; then
echo "valid=1" >> $GITHUB_OUTPUT
fi
- name: Cherry Pick All Related Changes in Master Branch
if: ${{ steps.check.outputs.valid }}
run: |
git checkout gh-pages
git checkout -b topic/github-action/update-gh-pages-$(date +'%Y%m%d')
git checkout master README.md releases/* docs/*
git add README.md releases/* docs/*
git commit -m":book:(docs) cherry-pick docs update from master to gh-pages"
git push -u origin topic/github-action/update-gh-pages-$(date +'%Y%m%d')
- name: Create Pull Request
if: ${{ steps.check.outputs.valid }}
run: |
gh pr create --title ":book:(docs) cherry-pick docs update to gh-pages" \
--body "This PR was created by GitHub Actions to update documentation in gh-pages branch" \
--base gh-pages --head topic/github-action/update-gh-pages-$(date +'%Y%m%d')
env:
GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}"