|
| 1 | +name: Deploy Documents |
| 2 | + |
| 3 | +env: |
| 4 | + PYTHON_VERSION: "3.9" |
| 5 | + |
| 6 | +on: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + # Branch to base "dev" website on. Set in siteversion.py also. |
| 10 | + - master |
| 11 | + # Release branches have names like 0.8.x, 0.9.x, ... |
| 12 | + - "[0-9]+.[0-9]+.x" |
| 13 | + create: |
| 14 | + |
| 15 | +jobs: |
| 16 | + publish-determination: |
| 17 | + runs-on: ubuntu-latest |
| 18 | + outputs: |
| 19 | + result: ${{ steps.determination.outputs.result }} |
| 20 | + steps: |
| 21 | + - name: Determine if documentation should be published on this workflow run |
| 22 | + id: determination |
| 23 | + run: | |
| 24 | + RELEASE_BRANCH_REGEX="refs/heads/[0-9]+.[0-9]+.x" |
| 25 | + if [[ "${{ github.event_name }}" == "push" || ( "${{ github.event_name }}" == "create" && "${{ github.ref }}" =~ $RELEASE_BRANCH_REGEX ) ]]; then |
| 26 | + RESULT="true" |
| 27 | + else |
| 28 | + RESULT="false" |
| 29 | + fi |
| 30 | +
|
| 31 | + echo "result=$RESULT" >> $GITHUB_OUTPUT |
| 32 | +
|
| 33 | + publish: |
| 34 | + runs-on: ubuntu-latest |
| 35 | + needs: publish-determination |
| 36 | + if: needs.publish-determination.outputs.result == 'true' |
| 37 | + |
| 38 | + steps: |
| 39 | + - name: Checkout repository |
| 40 | + uses: actions/checkout@v4 |
| 41 | + |
| 42 | + - name: Install Python |
| 43 | + uses: actions/setup-python@v5 |
| 44 | + with: |
| 45 | + python-version: ${{ env.PYTHON_VERSION }} |
| 46 | + |
| 47 | + - name: Create all generated documentation content |
| 48 | + run: mkdocs build |
| 49 | + |
| 50 | + - name: Determine versioning parameters |
| 51 | + id: determine-versioning |
| 52 | + run: echo 'data={"version":"5.4.0", alias="latest"}' >> $GITHUB_OUTPUT |
| 53 | + |
| 54 | + - name: Deploy |
| 55 | + if: fromJson(steps.determine-versioning.outputs.data).version != null |
| 56 | + run: | |
| 57 | + # Publishing implies creating a git commit on the gh-pages branch, we let @ArduinoBot own these commits. |
| 58 | + git config --global user.email "deploy@phalcon.io" |
| 59 | + git config --global user.name "Phalcon Team Deploy Bot" |
| 60 | + git fetch --no-tags --prune --depth=1 origin +refs/heads/production:refs/remotes/origin/production |
| 61 | + poetry run mike deploy \ |
| 62 | + --update-aliases \ |
| 63 | + --push \ |
| 64 | + --remote origin \ |
| 65 | + ${{ fromJson(steps.determine-versioning.outputs.data).version }} \ |
| 66 | + ${{ fromJson(steps.determine-versioning.outputs.data).alias }} |
0 commit comments