This repository has been archived by the owner on Sep 11, 2024. It is now read-only.
Deploy static content to Pages #367
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Simple workflow for deploying static content to GitHub Pages | |
name: Deploy static content to Pages | |
# Before changing any of these workflow triggers, make sure you understand the if statements for each of the jobs | |
on: | |
# Run automatically after the Android CI release finishes | |
workflow_run: | |
workflows: | |
- Android CI | |
branches: | |
- master | |
types: | |
- completed | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# Run on pull requests to master | |
pull_request: | |
# Note that this specifies the target branch, not the branch that the PR is from | |
branches: | |
- master | |
jobs: | |
build: | |
# Run if the Android CI build was successful, on PRs from docs/ branches, or if this is a manual workflow run | |
if: ${{ github.event.workflow_run.conclusion == 'success' || startsWith(github.head_ref, 'docs/') || github.event_name == 'workflow_dispatch' }} | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Build website | |
run: ./build.sh | |
working-directory: ./HelpPage/scripts/ | |
- name: Set up JDK | |
uses: actions/setup-java@v4 | |
with: | |
java-version: 11 | |
distribution: temurin | |
cache: gradle | |
- name: Build JavaDoc using Dokka | |
run: | | |
./gradlew :TeamCode:dokkaHtml --no-daemon | |
mv ./TeamCode/build/dokka/html ./HelpPage/build/javadoc | |
- name: Upload Pages build artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
name: github-pages-build | |
path: ./HelpPage/build | |
retention-days: 90 | |
deploy: | |
# Only run deployment from the master branch and not on pull requests | |
if: ${{ github.ref == 'refs/heads/master' && github.event_name != 'pull_request' }} | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: read | |
pages: write | |
id-token: write | |
# Only allow one concurrent deployment | |
concurrency: | |
group: pages-deploy | |
cancel-in-progress: false | |
steps: | |
- name: Configure Pages | |
uses: actions/configure-pages@v3 | |
- name: Download Pages build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: github-pages-build | |
- name: Extract Pages build artifact | |
run: | | |
mkdir pages-build | |
tar -xvf artifact.tar -C pages-build | |
- name: Download the latest APK | |
run: | | |
mkdir -p ./pages-build/apk/bin | |
cd ./pages-build/apk/bin | |
curl -LO https://github.com/XaverianTeamRobotics/FtcRobotController/releases/download/latest-ci-build/TeamCode-debug.apk | |
- name: Upload final Pages artifact | |
uses: actions/upload-pages-artifact@v2 | |
with: | |
name: github-pages-deploy | |
path: ./pages-build | |
retention-days: 90 | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v2 | |
with: | |
artifact_name: github-pages-deploy | |
test-deploy: | |
needs: | |
- build | |
runs-on: ubuntu-latest | |
# Only allow one concurrent test deployment per branch | |
concurrency: | |
group: pages-test-deploy-${{ github.ref }} | |
cancel-in-progress: true | |
steps: | |
- name: Download Pages build artifact | |
uses: actions/download-artifact@v3 | |
with: | |
name: github-pages-build | |
- name: Extract Pages build artifact | |
run: | | |
mkdir pages-build | |
tar -xvf artifact.tar -C pages-build | |
- name: Upload build to Cloudflare Pages | |
id: test-deployment | |
uses: cloudflare/pages-action@v1 | |
with: | |
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
projectName: xbhs-robotics-docs | |
directory: pages-build | |
- name: Add comment with test deployment URL | |
if: ${{ github.event_name == 'pull_request' }} | |
run: > | |
gh pr comment ${{ github.event.number }} | |
--repo ${{ github.repository }} | |
--body "Your docs changes were built successfully! | |
View a preview of them at ${{ steps.test-deployment.outputs.url }}" | |
env: | |
GH_TOKEN: ${{ github.token }} |