|
| 1 | +name: Update Combinator Docs |
| 2 | +on: |
| 3 | + push: |
| 4 | + branches: |
| 5 | + - main |
| 6 | + - master |
| 7 | +jobs: |
| 8 | + docs: |
| 9 | + runs-on: ubuntu-latest |
| 10 | + env: |
| 11 | + COMBINATOR_DOCS_FILE: docs/components/data/feast.md |
| 12 | + COMBINATOR_REPO: combinator-ml/combinator |
| 13 | + COMBINATOR_PATH: combinator |
| 14 | + LOCAL_PATH: local |
| 15 | + steps: |
| 16 | + - name: Checkout Local |
| 17 | + uses: actions/checkout@v2 |
| 18 | + with: |
| 19 | + path: ${{ env.LOCAL_PATH }} |
| 20 | + - name: Checkout Combinator Website |
| 21 | + uses: actions/checkout@v2 |
| 22 | + with: |
| 23 | + token: ${{ secrets.CI_TOKEN }} |
| 24 | + repository: ${{ env.COMBINATOR_REPO }} |
| 25 | + path: ${{ env.COMBINATOR_PATH }} |
| 26 | + - name: Checkout Branch |
| 27 | + run: | |
| 28 | + cd ${COMBINATOR_PATH} |
| 29 | + git checkout -b docs/${GITHUB_REPOSITORY} |
| 30 | + git pull origin docs/${GITHUB_REPOSITORY} || true |
| 31 | + - name: Copy Readme |
| 32 | + run: | |
| 33 | + cp ./${LOCAL_PATH}/README.md ./${COMBINATOR_PATH}/${COMBINATOR_DOCS_FILE} |
| 34 | + - name: Create PR |
| 35 | + env: |
| 36 | + GIT_USERNAME: action |
| 37 | + GIT_EMAIL: action@github.com |
| 38 | + run: | |
| 39 | + cd ${COMBINATOR_PATH} |
| 40 | + git config --local user.name "${GIT_USERNAME}" |
| 41 | + git config --local user.email "${GIT_EMAIL}" |
| 42 | + if [ -z "$(git status --porcelain)" ]; then |
| 43 | + echo "Your docs are up-to-date, no PR required." |
| 44 | + else |
| 45 | + echo "Docs are out of date" |
| 46 | + git --no-pager diff |
| 47 | + git add . |
| 48 | + git commit -m "docs: auto-update docs from ${GITHUB_REPOSITORY}" |
| 49 | + git push --set-upstream origin docs/${GITHUB_REPOSITORY} |
| 50 | + curl \ |
| 51 | + -X POST \ |
| 52 | + -H "Authorization: token ${{ secrets.CI_TOKEN }}" \ |
| 53 | + -H "Accept: application/vnd.github.v3+json" \ |
| 54 | + https://api.github.com/repos/${COMBINATOR_REPO}/pulls \ |
| 55 | + -d "{\"head\":\"docs/${GITHUB_REPOSITORY}\",\"base\":\"main\", \"title\": \"docs: auto-update docs from ${GITHUB_REPOSITORY}\"}" |
| 56 | + fi |
0 commit comments