|
| 1 | +name: Deploy Documentation |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: [ bleed ] |
| 6 | + tags: [ 'release-*', 'playtest-*' ] |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + tag: |
| 10 | + description: 'Git Tag' |
| 11 | + required: true |
| 12 | + default: 'release-xxxxxxxx' |
| 13 | + |
| 14 | +permissions: |
| 15 | + contents: read # to fetch code (actions/checkout) |
| 16 | + |
| 17 | +jobs: |
| 18 | + prepare: |
| 19 | + name: Prepare version strings |
| 20 | + if: github.repository == 'openra/openra' |
| 21 | + runs-on: ubuntu-22.04 |
| 22 | + steps: |
| 23 | + - name: Prepare environment variables |
| 24 | + run: | |
| 25 | + if [ "${{ github.event_name }}" = "push" ]; then |
| 26 | + if [ "${{ github.ref_type }}" = "tag" ]; then |
| 27 | + VERSION_TYPE=`echo "${GITHUB_REF#refs/tags/}" | cut -d"-" -f1` |
| 28 | + echo "GIT_TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV |
| 29 | + echo "VERSION_TYPE=$VERSION_TYPE" >> $GITHUB_ENV |
| 30 | + else |
| 31 | + echo "GIT_TAG=bleed" >> $GITHUB_ENV |
| 32 | + echo "VERSION_TYPE=bleed" >> $GITHUB_ENV |
| 33 | + fi |
| 34 | + else |
| 35 | + VERSION_TYPE=`echo "${{ github.event.inputs.tag }}" | cut -d"-" -f1` |
| 36 | + echo "GIT_TAG=${{ github.event.inputs.tag }}" >> $GITHUB_ENV |
| 37 | + echo "VERSION_TYPE=$VERSION_TYPE" >> $GITHUB_ENV |
| 38 | + fi |
| 39 | + outputs: |
| 40 | + git_tag: ${{ env.GIT_TAG }} |
| 41 | + version_type: ${{ env.VERSION_TYPE }} |
| 42 | + |
| 43 | + wiki: |
| 44 | + name: Update Wiki |
| 45 | + needs: prepare |
| 46 | + if: github.repository == 'openra/openra' && needs.prepare.outputs.version_type != 'bleed' |
| 47 | + runs-on: ubuntu-22.04 |
| 48 | + steps: |
| 49 | + - name: Debug output |
| 50 | + run: | |
| 51 | + echo ${{ needs.prepare.outputs.git_tag }} |
| 52 | + echo ${{ needs.prepare.outputs.version_type }} |
| 53 | +
|
| 54 | + - name: Clone Repository |
| 55 | + uses: actions/checkout@v4 |
| 56 | + with: |
| 57 | + ref: ${{ needs.prepare.outputs.git_tag }} |
| 58 | + |
| 59 | + - name: Install .NET 6 |
| 60 | + uses: actions/setup-dotnet@v4 |
| 61 | + with: |
| 62 | + dotnet-version: '6.0.x' |
| 63 | + |
| 64 | + - name: Prepare Environment |
| 65 | + run: | |
| 66 | + make all |
| 67 | +
|
| 68 | + - name: Clone Wiki |
| 69 | + uses: actions/checkout@v4 |
| 70 | + with: |
| 71 | + repository: openra/openra.wiki |
| 72 | + token: ${{ secrets.DOCS_TOKEN }} |
| 73 | + path: wiki |
| 74 | + |
| 75 | + - name: Update Wiki (Playtest) |
| 76 | + if: startsWith(needs.prepare.outputs.git_tag, 'playtest-') |
| 77 | + run: | |
| 78 | + ./utility.sh all --settings-docs "${{ needs.prepare.outputs.git_tag }}" > "wiki/Settings (playtest).md" |
| 79 | +
|
| 80 | + - name: Update Wiki (Release) |
| 81 | + if: startsWith(needs.prepare.outputs.git_tag, 'release-') |
| 82 | + run: | |
| 83 | + ./utility.sh all --settings-docs "${{ needs.prepare.outputs.git_tag }}" > "wiki/Settings.md" |
| 84 | +
|
| 85 | + - name: Push Wiki |
| 86 | + run: | |
| 87 | + cd wiki |
| 88 | + git config --local user.email "actions@github.com" |
| 89 | + git config --local user.name "GitHub Actions" |
| 90 | + git status |
| 91 | + git diff-index --quiet HEAD || \ |
| 92 | + ( |
| 93 | + git add --all && \ |
| 94 | + git commit -m "Update auto-generated documentation for ${{ needs.prepare.outputs.git_tag }}" && \ |
| 95 | + git push origin master |
| 96 | + ) |
| 97 | +
|
| 98 | + docs: |
| 99 | + name: Update docs.openra.net |
| 100 | + needs: prepare |
| 101 | + if: github.repository == 'openra/openra' |
| 102 | + runs-on: ubuntu-22.04 |
| 103 | + steps: |
| 104 | + - name: Debug output |
| 105 | + run: | |
| 106 | + echo ${{ needs.prepare.outputs.git_tag }} |
| 107 | + echo ${{ needs.prepare.outputs.version_type }} |
| 108 | +
|
| 109 | + - name: Clone Repository |
| 110 | + uses: actions/checkout@v4 |
| 111 | + with: |
| 112 | + ref: ${{ needs.prepare.outputs.git_tag }} |
| 113 | + |
| 114 | + - name: Install .NET 6 |
| 115 | + uses: actions/setup-dotnet@v4 |
| 116 | + with: |
| 117 | + dotnet-version: '6.0.x' |
| 118 | + |
| 119 | + - name: Prepare Environment |
| 120 | + run: | |
| 121 | + make all |
| 122 | +
|
| 123 | + # version_type is release/playtest/bleed - the name of the target branch. |
| 124 | + - name: Clone docs.openra.net |
| 125 | + uses: actions/checkout@v4 |
| 126 | + with: |
| 127 | + repository: openra/docs |
| 128 | + token: ${{ secrets.DOCS_TOKEN }} |
| 129 | + path: docs |
| 130 | + ref: ${{ needs.prepare.outputs.version_type }} |
| 131 | + |
| 132 | + - name: Generate docs files |
| 133 | + run: | |
| 134 | + ./utility.sh all --docs "${{ needs.prepare.outputs.git_tag }}" | python3 ./packaging/format-docs.py > "docs/api/traits.md" |
| 135 | + ./utility.sh all --weapon-docs "${{ needs.prepare.outputs.git_tag }}" | python3 ./packaging/format-docs.py > "docs/api/weapons.md" |
| 136 | + ./utility.sh all --sprite-sequence-docs "${{ needs.prepare.outputs.git_tag }}" | python3 ./packaging/format-docs.py > "docs/api/sprite-sequences.md" |
| 137 | + ./utility.sh all --lua-docs "${{ needs.prepare.outputs.git_tag }}" > "docs/api/lua.md" |
| 138 | +
|
| 139 | + - name: Update docs.openra.net |
| 140 | + run: | |
| 141 | + cd docs |
| 142 | + git config --local user.email "actions@github.com" |
| 143 | + git config --local user.name "GitHub Actions" |
| 144 | + git status |
| 145 | + git diff-index --quiet HEAD || \ |
| 146 | + ( |
| 147 | + git add api/*.md && \ |
| 148 | + git commit -m "Update auto-generated documentation for ${{ needs.prepare.outputs.git_tag }}" && \ |
| 149 | + git push origin ${{ needs.prepare.outputs.version_type }} |
| 150 | + ) |
0 commit comments