comments and cleanup #18
Workflow file for this run
This file contains hidden or 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
| name: Deploy docs to Pages | |
| on: | |
| push: | |
| paths: | |
| - '**.roc' | |
| release: | |
| types: | |
| - created | |
| workflow_dispatch: | |
| # this cancels workflows currently in progress if you start a new one | |
| concurrency: | |
| group: "pages" | |
| cancel-in-progress: true | |
| # Do not add permissions here! Configure them at the job level! | |
| permissions: | |
| contents: read | |
| jobs: | |
| deploy: | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| pages: write | |
| id-token: write | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Downloading latest roc nightly | |
| run: | | |
| curl -fOL https://github.com/roc-lang/roc/releases/download/nightly/roc_nightly-linux_x86_64-latest.tar.gz | |
| - name: prep nightly tar for use | |
| run: | | |
| mv $(ls | grep "roc_nightly.*tar\.gz") roc_nightly.tar.gz | |
| tar -xzf roc_nightly.tar.gz | |
| rm roc_nightly.tar.gz | |
| mv roc_nightly* roc_nightly | |
| - run: ./roc_nightly/roc version | |
| - name: Create temp directory for docs | |
| run: mkdir -p ./temp_docs | |
| - name: Download and extract docs for each release | |
| run: | | |
| # Get all releases | |
| releases=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "https://api.github.com/repos/roc-lang/basic-cli/releases" | jq -c '.') | |
| echo "$releases" | jq -c '.[]' | while read -r release; do | |
| release_name=$(echo $release | jq -r '.tag_name') | |
| assets_url=$(echo $release | jq -r '.assets_url') | |
| # Get assets for this release | |
| assets=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" "${assets_url}") | |
| # Look for docs.tar.gz asset | |
| download_url=$(echo $assets | jq -r '.[] | select(.name=="docs.tar.gz") | .browser_download_url') | |
| if [ ! -z "$download_url" ]; then | |
| echo "Processing release ${release_name}, downloading from ${download_url}" | |
| # Create directory for this release | |
| mkdir -p "./temp_docs/${release_name}" | |
| # Download and extract | |
| curl -sL "${download_url}" -o ./temp_docs/temp.tar.gz | |
| tar -xzf ./temp_docs/temp.tar.gz -C "./temp_docs/${release_name}" --strip-components=1 | |
| rm ./temp_docs/temp.tar.gz | |
| else | |
| echo "Error: docs.tar.gz not found for release ${release_name}" | |
| fi | |
| done | |
| # fix URLs | |
| find ./temp_docs -type f -exec sed -i 's/\/packages\/basic-cli\//\/basic-cli\//g' {} + | |
| # Get the latest release version | |
| latest_release=$(echo "${releases}" | jq -r '.[0].tag_name') | |
| if [ -f "./docs/index.html" ]; then | |
| # Copy the index.html and replace LATESTVERSION with actual latest release | |
| cat ./docs/index.html | sed "s/LATESTVERSION/${latest_release}/g" > ./temp_docs/index.html | |
| echo "Created index.html with latest version: ${latest_release}" | |
| else | |
| echo "Error: index.html not found in docs folder" | |
| exit 1 | |
| fi | |
| - name: Add docs for main branch | |
| env: | |
| ROC_DOCS_URL_ROOT: /basic-cli/main | |
| run: | | |
| ./roc_nightly/roc docs ./platform/main.roc | |
| mkdir -p "./temp_docs/main" | |
| mv ./generated-docs/* ./temp_docs/main | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v3 | |
| with: | |
| # Upload the processed docs folder | |
| path: "./temp_docs" | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 |