Check API Docs Update #141
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Check API Docs Update | |
on: | |
schedule: | |
- cron: '* 3 * * *' | |
workflow_dispatch: | |
#branches: [ * ] | |
permissions: | |
contents: write | |
env: | |
DEFAULT_BRANCH: "main" | |
jobs: | |
check-and-update: | |
runs-on: ubuntu-latest | |
if: ${{ github.repository_owner == 'platformsh' }} | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Set up Git | |
run: | | |
git config --global user.name "github-actions[bot]" | |
git config --global user.email "github-actions[bot]@users.noreply.github.com" | |
- name: Download redoc_static.html from GitLab | |
env: | |
GITLAB_TOKEN: ${{ secrets.GITLAB_TOKEN }} | |
run: | | |
PROJECT_PATH="devrel/docs/api-site" | |
REF="main" | |
# URL-encode path to the project (replace `/` by `%2F`) | |
# @todo switch this to using the python method so we're consistent? | |
PROJECT_ENCODED=$(echo "$PROJECT_PATH" | sed 's/\//%2F/g') | |
# Download into shared data using the GitLab API | |
# @todo should we also copy over the stylesheet? or should the version in docs be canonical? | |
curl --header "PRIVATE-TOKEN: $GITLAB_TOKEN" \ | |
--output shared/pages/api.html \ | |
"https://lab.plat.farm/api/v4/projects/${PROJECT_ENCODED}/repository/files/$(python3 -c "import urllib.parse; print(urllib.parse.quote('web/redoc-static.html',safe=''))")/raw?ref=${REF}" | |
- name: Create Pull Request if changes | |
uses: peter-evans/create-pull-request@v6 | |
with: | |
token: ${{ secrets.WORKFLOW_TOKEN }} | |
commit-message: "Update API Docs" | |
body: "This PR updates the API Docs." | |
author: ${{ github.actor }} <${{ github.actor_id }}+${{ github.actor }}@users.noreply.github.com> | |
signoff: false | |
draft: false | |
delete-branch: true | |
branch: update-api-doc | |
title: "[API-BOT] Update API Docs" | |
base: main | |
labels: | | |
report | |
automated pr | |
add-paths: | | |
shared/pages |