aboutsummaryrefslogtreecommitdiff
path: root/.github/workflows/update-documentation.yml
blob: 8e39b3f29fae2151e6bc091c25b2a3e8fb04e34b (plain) (blame)
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
name: "Update Documentation"
on:
  push:
    branches:
      - main
  workflow_dispatch:

jobs:
  generate:
    runs-on: ubuntu-latest
    if: "!contains(github.event.head_commit.message, 'no-ci') && !contains(github.event.head_commit.message, 'CI ignore')"
    steps:
      - uses: actions/checkout@v2

      - name: Generate Documentation
        uses: ./.github/devcontainers-action # devcontainers/action
        with:
          generate-docs: "true"
          base-path-to-features: "./src"

      - name: Add and Commit Documentation
        id: push_image_info
        run: |
          set -e
          echo "Start."

          GIT_BRANCH=$(echo "${{ github.ref }}" | grep -oP 'refs/(heads|tags)/\K(.+)')
          if [ "$GIT_BRANCH" == "" ]; then 
              echo "ERR: Could not determine branch."
              exit 1
          fi

          echo "GIT_BRANCH = ${GIT_BRANCH}"
          
          git config --global user.email "vscr-feedback@microsoft.com"
          git config --global user.name "Devcontainers CI"
          git config pull.rebase false

          # # Pull in anything that may have come in
          # git pull "https://ci:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" "HEAD:$GIT_BRANCH"

          # Add / update and commit
          git add */**/README.md
          git status
          git commit -m 'Automated documentation update' || export NO_UPDATES=true

          # Push
          if [ "$NO_UPDATES" != "true" ] ; then
              git push "https://ci:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}" "HEAD:$GIT_BRANCH"
          fi