From 5e1fa685488c8cfcc910f246bfec3da45b46d58e Mon Sep 17 00:00:00 2001 From: Silvano Cerza Date: Wed, 14 Oct 2020 12:52:35 +0200 Subject: [PATCH 1/2] [skip changelog] Split publish docs workflow --- .github/workflows/publish-dev-docs.yaml | 70 +++++++++++++++++++++++++ .github/workflows/publish-docs.yaml | 8 --- 2 files changed, 70 insertions(+), 8 deletions(-) create mode 100644 .github/workflows/publish-dev-docs.yaml diff --git a/.github/workflows/publish-dev-docs.yaml b/.github/workflows/publish-dev-docs.yaml new file mode 100644 index 00000000000..51535dcb591 --- /dev/null +++ b/.github/workflows/publish-dev-docs.yaml @@ -0,0 +1,70 @@ +name: publish-docs + +on: + push: + branches: + - master + # At this day, GitHub doesn't support YAML anchors, d'oh! + paths: + - "docs/**" + - "docsgen/**" + - "cli/**" + - "rpc/**" + - ".github/workflows/publish-docs.yaml" + +jobs: + publish: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v2 + + - name: Install Taskfile + uses: Arduino/actions/setup-taskfile@master + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: "1.14" + + - name: Install Go dependencies + run: | + go version + go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc + + - name: Install protoc compiler + uses: arduino/setup-protoc@v1 + with: + repo-token: ${{ secrets.GITHUB_TOKEN }} + + - name: Setup Python + uses: actions/setup-python@v1 + with: + python-version: "3.8" + architecture: "x64" + + - name: Cache dependencies + uses: actions/cache@v1 + with: + path: ~/.cache/pip + key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} + restore-keys: | + ${{ runner.os }}-pip- + + - name: Install Python dependencies + run: | + python3 -m pip install --upgrade pip + python3 -m pip install -r ./requirements_docs.txt + + - name: Publish docs + # Determine docs version for the commit pushed and publish accordingly using Mike. + # Publishing implies creating a git commit on the gh-pages branch, we let + # ArduinoBot own these commits. + run: | + git config --global user.email "bot@arduino.cc" + git config --global user.name "ArduinoBot" + git fetch --no-tags --prune --depth=1 origin +refs/heads/gh-pages:refs/remotes/origin/gh-pages + python docs/build.py diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index d06ff67eaa7..fecbbc951ac 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -3,16 +3,8 @@ name: publish-docs on: push: branches: - - master # release branches have names like 0.8.x, 0.9.x, ... - "[0-9]+.[0-9]+.x" - # At this day, GitHub doesn't support YAML anchors, d'oh! - paths: - - "docs/**" - - "docsgen/**" - - "cli/**" - - "rpc/**" - - ".github/workflows/publish-docs.yaml" jobs: publish: From b393eb54c388527a43170dfcc5c6ebf3d8e03e19 Mon Sep 17 00:00:00 2001 From: per1234 Date: Wed, 14 Oct 2020 09:41:47 -0700 Subject: [PATCH 2/2] Always publish documentation on creation of release branch Previously, release branch creation did not trigger documentation publishing. --- .github/workflows/publish-dev-docs.yaml | 70 ------------------------- .github/workflows/publish-docs.yaml | 29 ++++++++++ 2 files changed, 29 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/publish-dev-docs.yaml diff --git a/.github/workflows/publish-dev-docs.yaml b/.github/workflows/publish-dev-docs.yaml deleted file mode 100644 index 51535dcb591..00000000000 --- a/.github/workflows/publish-dev-docs.yaml +++ /dev/null @@ -1,70 +0,0 @@ -name: publish-docs - -on: - push: - branches: - - master - # At this day, GitHub doesn't support YAML anchors, d'oh! - paths: - - "docs/**" - - "docsgen/**" - - "cli/**" - - "rpc/**" - - ".github/workflows/publish-docs.yaml" - -jobs: - publish: - runs-on: ubuntu-latest - - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Install Taskfile - uses: Arduino/actions/setup-taskfile@master - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup Go - uses: actions/setup-go@v2 - with: - go-version: "1.14" - - - name: Install Go dependencies - run: | - go version - go get -u github.com/pseudomuto/protoc-gen-doc/cmd/protoc-gen-doc - - - name: Install protoc compiler - uses: arduino/setup-protoc@v1 - with: - repo-token: ${{ secrets.GITHUB_TOKEN }} - - - name: Setup Python - uses: actions/setup-python@v1 - with: - python-version: "3.8" - architecture: "x64" - - - name: Cache dependencies - uses: actions/cache@v1 - with: - path: ~/.cache/pip - key: ${{ runner.os }}-pip-${{ hashFiles('**/requirements.txt') }} - restore-keys: | - ${{ runner.os }}-pip- - - - name: Install Python dependencies - run: | - python3 -m pip install --upgrade pip - python3 -m pip install -r ./requirements_docs.txt - - - name: Publish docs - # Determine docs version for the commit pushed and publish accordingly using Mike. - # Publishing implies creating a git commit on the gh-pages branch, we let - # ArduinoBot own these commits. - run: | - git config --global user.email "bot@arduino.cc" - git config --global user.name "ArduinoBot" - git fetch --no-tags --prune --depth=1 origin +refs/heads/gh-pages:refs/remotes/origin/gh-pages - python docs/build.py diff --git a/.github/workflows/publish-docs.yaml b/.github/workflows/publish-docs.yaml index fecbbc951ac..ed4f8c672c2 100644 --- a/.github/workflows/publish-docs.yaml +++ b/.github/workflows/publish-docs.yaml @@ -3,12 +3,41 @@ name: publish-docs on: push: branches: + - master # release branches have names like 0.8.x, 0.9.x, ... - "[0-9]+.[0-9]+.x" + # At this day, GitHub doesn't support YAML anchors, d'oh! + paths: + - "docs/**" + - "docsgen/**" + - "cli/**" + - "rpc/**" + - ".github/workflows/publish-docs.yaml" + # On branch or tag creation (will be filtered by the publish-determination job) + create: jobs: + publish-determination: + runs-on: ubuntu-latest + outputs: + result: ${{ steps.determination.outputs.result }} + steps: + - name: Determine if documentation should be published on this workflow run + id: determination + run: | + RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x" + if [[ "${{ github.event_name }}" == "push" || ( "${{ github.event_name }}" == "create" && "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX ) ]]; then + RESULT="true" + else + RESULT="false" + fi + + echo "::set-output name=result::$RESULT" + publish: runs-on: ubuntu-latest + needs: publish-determination + if: needs.publish-determination.outputs.result == 'true' steps: - name: Checkout