Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 32 additions & 2 deletions .github/scripts/pushdocs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ PAGES_REPO="ibm-verify.github.io"
PAGES_BRANCH="main"
DESTINATION_ROOT="${GITHUB_WORKSPACE}/docs"
SOURCE_ROOT="${GITHUB_WORKSPACE}/monorepo"
TIMESTAMP=$(date +%Y%m%d%H%M%S)
BRANCH_NAME="feature/auto-pr-${{ github.run_id }}-${TIMESTAMP}"

echo "Generated branch name: $BRANCH_NAME"

# generate sdk docs and copy to respective locations
for MODULE in `ls -d $SOURCE_ROOT/sdk/*`
Expand All @@ -19,11 +23,37 @@ done
cd ${SOURCE_ROOT}
MESSAGE=`git log --format=%B -n 1`
cd ${DESTINATION_ROOT}

# suppress GH token in the authorization header.
# thanks to https://stackoverflow.com/a/64271581/5099773
git config -l | grep 'http\..*\.extraheader' | cut -d= -f1 | \
xargs -L1 git config --unset-all

# set up git config
git config user.email "shankarv@sg.ibm.com"
git config user.name "shankarv"

# switch to a feature branch
git checkout -b $BRANCH_NAME

# commit changes
git add -A
git diff-index --quiet HEAD || git commit -m "${MESSAGE}"
git push -u https://${PAGES_USER}:${GH_PAGES_TOKEN}@github.com/${PAGES_USER}/${PAGES_REPO}
git commit -m "${MESSAGE}"
git status

# push to repo
git push -u origin $BRANCH_NAME

# create a PR
gh pr create \
--body "" \
--title "docs(auto): update documentation" \
--head "$BRANCH_NAME" \
--base "master"

# git config --get remote.origin.url
# git remote set-url origin https://${{ secrets.GH_PAGES_TOKEN }}@github.com/${PAGES_USER}/${PAGES_REPO}
# git push origin
# git config --get remote.origin.url

# git push -u https://${PAGES_USER}:${GH_PAGES_TOKEN}@github.com/${PAGES_USER}/${PAGES_REPO}
6 changes: 6 additions & 0 deletions .github/workflows/pushdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ jobs:
with:
node-version: '12'

- name: Authorize GitHub CLI
env:
GITHUB_TOKEN: ${{ secrets.GH_PAGES_API_TOKEN }}
run: |
gh auth login --with-token <<< "$GITHUB_TOKEN"

- name: Push docs
run: ${{ github.workspace }}/monorepo/.github/scripts/pushdocs.sh
shell: bash